Copy/Paste Data from row above to blank row below - every 2nd row

jessitarexcel

Board Regular
Joined
Apr 6, 2022
Messages
60
Office Version
  1. 365
Platform
  1. Windows
  2. Mobile
  3. Web
Hello,

I currently have over 300 rows of data. The data that I want to copy is below and has been de-identified. The data that needs to be copied is in the yellow cells in rows 2,4,6,8, etc. The data needs to be copied from above and copied in to the blank (orange) row below.

1649301013742.png


This needs to occur for every second row.

I am currently looking at two pieces of code that I have taken from this website on another topic:

VBA Code:
Sub CopyDown()

    lastRow = Range("A" & Rows.Count).End(xlUp).Row + 4
    i = 1
    j = 5
    
While i < lastRow

    Sheets(1).Range("A" & i & ":D" & i).Copy Sheets(1).Range("A" & i & ":D" & j)
    i = i + 5
    j = j + 5

Wend

End Sub

Can someone please explain to me what the "i" and the "j" refer to in this code please? I believe Bill was the original person who wrote the code.

And the following code:

VBA Code:
Sub CopyDown()
    
    Dim UsdRws As Long
    Dim Cnt As Long
    
    UsdRws = Range("A" & Rows.Count).End(xlUp).Offset(4).Row
    
    For Cnt = 1 To UsdRws Step 5
        Range("A" & Cnt).Resize(5, 4).FillDown
    Next Cnt
    

End Sub

Can someone please explain to me what the Resize(5,4) means? Does that mean that it moves down 5 rows and across 4 columns?

Any help would be very much appreciated.
 

Excel Facts

Who is Mr Spreadsheet?
Author John Walkenbach was Mr Spreadsheet until his retirement in June 2019.
Sorry that should say 30,000 rows of data, not 300. Any help with the code would be appreciated.
 
Upvote 0

Forum statistics

Threads
1,224,828
Messages
6,181,209
Members
453,022
Latest member
RobertV1609

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top