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

Shade all formula cells
To shade all formula cells: Home, Find & Select, Formulas to select all formulas. Then apply a light fill color.
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,215,883
Messages
6,127,541
Members
449,385
Latest member
KMGLarson

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