Hello,
I have an excel file where I need to loop through the data 12 times and what I want to do is copy the data from a certain range in this case column G2:H2
And then I want to paste it one row below and the last row with current data for column G:H and down to the last row based on column A.
The code below does not show the code for the A column but during the macro the A column will also have data in more row
So let say the first time prior to running the code below the column A has 25 rows
So I want the data to be pasted from G3:H25
Next time A column has data to row 50
Copy data from G25:H25
Paste to G26:H50
I don’t know how I can use last row count to the first range variable and the end cell
Please help me!
I have an excel file where I need to loop through the data 12 times and what I want to do is copy the data from a certain range in this case column G2:H2
And then I want to paste it one row below and the last row with current data for column G:H and down to the last row based on column A.
The code below does not show the code for the A column but during the macro the A column will also have data in more row
So let say the first time prior to running the code below the column A has 25 rows
So I want the data to be pasted from G3:H25
Next time A column has data to row 50
Copy data from G25:H25
Paste to G26:H50
I don’t know how I can use last row count to the first range variable and the end cell
VBA Code:
For i = 1 to 12
LR = ActiveSheet.Range("A" & Rows.Count).End(xlUp).Row
ActiveSheet.Range(“G2:H2”).select
Selection.copy
Activesheet.range(“G3:H" & LR+1).PasteSpecial xlPasteValues
Next
Please help me!