Macro to copy data from every nth row to another sheet

sshirazi

New Member
Joined
Aug 5, 2016
Messages
7
Need a macro to populate data from source "sheet1" to destination "Sheet2". The data to be copied from sheet1 is on every 43 row except the first & in 14 columns. e.g

From Row N41:O41 & R41:AC41 "Sheet1"
to Row N6:O6 & Q6:AB6 "Sheet2"
From Row N84:O84 & R84:AC84 "Sheet1"
To Row N7:O7 & Q7:AB7 "Sheet2"
From Row N127:O127 & R127:AC127 "Sheet1"
To Row N8:O8 & Q8:AB8 "Sheet2"

Thanks for help!
 

Excel Facts

Difference between two dates
Secret function! Use =DATEDIF(A2,B2,"Y")&" years"&=DATEDIF(A2,B2,"YM")&" months"&=DATEDIF(A2,B2,"MD")&" days"
Hi sshirazi,

Here's one way:

Code:
Option Explicit
Sub Macro1()

    Dim varCellsFrom As Variant
    Dim varCellsTo As Variant
    Dim lngArrayIndex As Long
    
    Application.ScreenUpdating = False
    
    varCellsFrom = Array("N41:O41", "R41:AC41", "N84:O84", "R84:AC84", "N127:O127", "R127:AC127")
    varCellsTo = Array("N6:O6", "Q6:AB6", "N7:O7", "Q7:AB7", "N8:O8", "Q8:AB8")
    
    For lngArrayIndex = LBound(varCellsFrom) To UBound(varCellsTo)
        Sheets("Sheet1").Range(CStr(varCellsFrom(lngArrayIndex))).Copy Destination:=Sheets("Sheet2").Range(CStr(varCellsTo(lngArrayIndex)))
    Next lngArrayIndex
    
    Application.ScreenUpdating = True

End Sub

Regards,

Robert
 
Upvote 0

Forum statistics

Threads
1,223,997
Messages
6,175,872
Members
452,679
Latest member
darryl47nopra

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