Copying and paste in Excel is quite simple and straight
forward.
It should be the same thing with VBA, there are few ways to
do this via VBA.
The simple is to record a Macro then check the code, then
alter the data to suits the operation that needs to be done.
Basically, when copying and paste; it’s like pointing the
data to another cell or cells so both locations will have the same value or
data.
The code example below, does the above strategy. Get the
value of the data that is to will be copied and point the data to a location
where the data will be pasted.
Here's the Excel Vba code to copy and paste:
Sub CopyandPaste()
Set wb2 = ThisWorkbook
'Copy or set the value to be copied to a variable
string_row_value = wb2.Sheets("Sheet1").Cells(1,
1).Value
'Paste or set the value to Sheet2
wb2.Sheets("Sheet2").Cells(1, 2).Value =
string_row_value
'If needs to be copied to the same worksheet or in sheet1
itself
'Basically just define sheet name and the location where the
value is to be paste
wb2.Sheets("Sheet1").Cells(2, 2).Value = string_row_value
'Cells(1,1) = Cells (row, column)
'Cells(1,1) = A1
'Cells(1, 2) = B1
'Cells(2, 2) = B2
End Sub
Cheers..Till next time. Hope it helps. 😊
================================
Free Android Apps:
Click links below to find out more:
Excel Keyboard guide:
Heaven's Dew Fall Prayer app for Android :
Catholic Rosary Guide for Android:
Pray the Rosary every day, countless blessings will be showered upon your life if you recite the Rosary faithfully.
https://play.google.com/store/apps/details?id=com.myrosaryapp
https://play.google.com/store/apps/details?id=com.myrosaryapp
Comments
Post a Comment