How to Copy Every Nth Row in Excel (3 Easy Methods)

We will use the following dataset to highlight the methods to copy every nth row in Excel.

dataset to copy every nth row


Method 1 – Use OFFSET and ROW Functions

  • Let’s copy every 3rd row starting from the 1st row.
  • Apply the following formula in cell E5 and drag the Fill Handle icon down. You may need to apply proper formatting to the Date and Sales columns.
=OFFSET($B$5:$C$5,(ROW(A1)-1)*3,0)

formula to copy every nth row

  • If you want to copy every 4th row starting from the 1st row, change the 3 in the formula to 4.

formula to copy every 4th row

  • Enter the following formula instead if you wish to copy every 3rd row, starting from the 3rd row. Change the 3 in the formula to 4, 5, 6 to copy every 4th, 5th, 6th row, and so on.
=OFFSET($B$5:$C$5,ROW(A1)*3-1,0)

OFFSET function to copy every nth row


Method 2 – Utilize the IF, MOD, and ROW Functions

  • Let’s copy every other row starting from the first row. Apply the following formula in cell E5 and drag the Fill Handle icon down.
=IF(MOD(ROW(A1),2)=1,B5:C5,"")
  • Change the 2 in the formula to 3, 4, 5 to copy the 3rd, 4th, 5th row, and so on.

create formula using IF, MOD and ROW function


Method 3 – Copy Every Nth Row in Excel VBA

  • Go to the Developer tab and select Visual Basic or press Alt + F11 to open the VBA Editor.
  • Select Insert and choose Module. This will create a new blank module.

insert module in VB editor

  • Copy the following code and paste it onto the blank module.
Sub CopyEveryNthRow()
N = CInt(Application.InputBox("Value of N:", _
"Copy Every Nth Row", , , , , , 1))
ST_Row = CInt(Application.InputBox("Starting row number", _
"Copy Every Nth Row", , , , , , 1))
Set IRange = Application.InputBox(Prompt:="Select range:", _
Title:="Copy Every Nth Row", _
Default:=Selection.Address, Type:=8)
r = 5
Count = CInt(IRange.Rows.CountLarge)
For i = ST_Row To CInt(Count) Step N
IRange.Rows(i).Copy Range("E" & r)
r = r + 1
Next i
End Sub

VBA code to copy every nth row

  • Press F5 to run the code. You will be asked for the value of N, the starting row number, and the data range.
  • Suppose you want to copy every 3rd (N = 3) row starting from the 1st row (row number = 1) in the sample data range (B5:C16)
  • The output result will be as follows.

VBA returns every nth row

Read More: Copy Alternate Rows in Excel


How to Copy Every Other Row Using the Fill Handle in Excel

  • Let’s copy every other row in range E:F as follows.

copy to range

  • Enter =B5 in cell E5 and drag the Fill Handle icon to the right.

copy first row

  • Excel will show an error in cell F5 as the formatting of cell E5 will also be copied there. Click on the error icon and select Update format.

update format error

  • Select these two cells along with the adjacent two cells below.
  • Drag down the Fill Handle icon from the selection.

select top row with n blank rows

  • Every other row will be copied as follows.

copy every other row

  • Filter out the blank rows to copy the data as shown below.

filter out blank rows

  • If you want to skip the first row, start with the reference from the second row (B6) instead.

skip the first row

  • To copy every third row, start with the cell reference from the third row (B7) and drag down two more blank rows with the top row. Increase the number of blanks for every row you want to remove.

copy every 3rd row using Fill Handle

Read More: Copy and Paste Thousands of Rows in Excel


Things to Remember

  • You need to press Ctrl + Shift + Enter to apply array formulas if you are not using Excel 365.
  • Save the file as a macro-enabled workbook to avoid losing VBA code.

Download the Practice Workbook


Related Articles


<< Go Back to Copy Rows | Copy Paste in Excel | Learn Excel

Get FREE Advanced Excel Exercises with Solutions!
Md. Shamim Reza
Md. Shamim Reza

Md. Shamim Reza, a marine engineer with expertise in Excel and a fervent interest in VBA programming, sees programming as a time-saving tool for data manipulation, file handling, and internet interaction. His diverse skill set encompasses Rhino3D, Maxsurf C++, AutoCAD, Deep Neural Networks, and Machine Learning. He holds a B.Sc in Naval Architecture & Marine Engineering from BUET and has transitioned into a content developer role, generating technical content focused on Excel and VBA. Beyond his professional pursuits,... Read Full Bio

We will be happy to hear your thoughts

Leave a reply

Advanced Excel Exercises with Solutions PDF

 

 

ExcelDemy
Logo