Skip to main content

How to select every other or nth row in Excel?

When we use a worksheet, sometimes, we need to select the every other or nth row of the sheet for formatting, deleting or copying purpose. You can select them manually, but if there are hundreds of rows, this method is not a good choice. Here are some tricks to help you.

Select every other or nth row with VBA

Select every other or nth row with Kutools for Excelgood idea3


Select every other or nth row with VBA

In this example, I will select one row with two intervals. With VBA code, I can finish it as follows:

1. Highlight the range that you want to select every other or nth row.

2.Click Developer > Visual Basic, a new Microsoft Visual Basic for applications window will be displayed, click Insert > Module, and input the following code into the Module:

Sub EveryOtherRow()
Dim rng As Range
Dim InputRng As Range
Dim OutRng As Range
Dim xInterval As Integer
xTitleId = "KutoolsforExcel"
Set InputRng = Application.Selection
Set InputRng = Application.InputBox("Range :", xTitleId, InputRng.Address, Type:=8)
xInterval = Application.InputBox("Enter row interval", xTitleId, Type:=1)
For i = 1 To InputRng.Rows.Count Step xInterval + 1
    Set rng = InputRng.Cells(i, 1)
    If OutRng Is Nothing Then
        Set OutRng = rng
    Else
        Set OutRng = Application.Union(OutRng, rng)
    End If
Next
OutRng.EntireRow.Select
End Sub

3.Then click doc-multiply-calculation-3 button to run the code. And a dialog pops up for you to select a range. See screenshot:



4. Click OK, and in this case, I input 3 in the another pop out dialog as the interval row. See screenshot

5. Click OK, and the every third row has been selected. See screenshot:

You can change the interval as you need in the second KutoolsforExcel dialog.


Select every other or nth row with Kutools for Excel

With VBA code, you can only select one row with specified intervals, if you need to select two, three or other rows with specified intervals, the Kutools for Excel can help you solve this problem easily and conveniently.

Kutools for Excel, with more than 300 handy functions, makes your jobs more easier. 

After free installing Kutools for Excel, please do as below:

1. Click Kutools > Select > Select Interval Rows & Columns…,see screenshot:

doc select every other row8

2. In the  Select Interval Rows & Columns dialog box,  clickdoc-replace-range-names-7 button to select the range you need, choose Rows or Columns from Select section, and specify the number you want in the Interval of input box and Rows input box. See screenshot:

doc select every other row9

doc select every other row10

Notes:
1. If you need to select every other row in the selection, please enter 2 in the Intervals of Input box and 1 in the Rows input box.

2. If you want to select the entire row that you need, you can check Select entire rows option.
doc select every other row11


Shade every other row or nth row with Kutools for Excel

If you want to shade ranges in every other row so that the data looks more outstanding as below screenshot shown, you can apply Kutools for Excel’s Alternate Row/Column Shading function to quickly handle the job.

doc select every other row12
doc arrow down
doc select every other row13

After free installing Kutools for Excel, please do as below:

1. Select the range of cells you want to interval shade, click Kutools > Format > Alternate Row/Column Shading.
doc select every other row14

2. In the Alternate Row/Column Shading dialog, do as these:

1)Select the rows or columns you want to shade;

2)Choose Conditional formatting or standard formatting as you need;

3)Specify shading interval;

4)Choose a shading color.
doc select every other row15

3. Click Ok. Now the range has been shaded in every nth row.

If you want to remove the shading, check Remove existing alternate row shading option in Alternate Row/Column Shading dialog.


Related articles:

Best Office Productivity Tools

🤖 Kutools AI Aide: Revolutionize data analysis based on: Intelligent Execution   |  Generate Code  |  Create Custom Formulas  |  Analyze Data and Generate Charts  |  Invoke Kutools Functions
Popular Features: Find, Highlight or Identify Duplicates   |  Delete Blank Rows   |  Combine Columns or Cells without Losing Data   |   Round without Formula ...
Super Lookup: Multiple Criteria VLookup    Multiple Value VLookup  |   VLookup Across Multiple Sheets   |   Fuzzy Lookup ....
Advanced Drop-down List: Quickly Create Drop Down List   |  Dependent Drop Down List   |  Multi-select Drop Down List ....
Column Manager: Add a Specific Number of Columns  |  Move Columns  |  Toggle Visibility Status of Hidden Columns  |  Compare Ranges & Columns ...
Featured Features: Grid Focus   |  Design View   |   Big Formula Bar    Workbook & Sheet Manager   |  Resource Library (Auto Text)   |  Date Picker   |  Combine Worksheets   |  Encrypt/Decrypt Cells    Send Emails by List   |  Super Filter   |   Special Filter (filter bold/italic/strikethrough...) ...
Top 15 Toolsets12 Text Tools (Add Text, Remove Characters, ...)   |   50+ Chart Types (Gantt Chart, ...)   |   40+ Practical Formulas (Calculate age based on birthday, ...)   |   19 Insertion Tools (Insert QR Code, Insert Picture from Path, ...)   |   12 Conversion Tools (Numbers to Words, Currency Conversion, ...)   |   7 Merge & Split Tools (Advanced Combine Rows, Split Cells, ...)   |   ... and more

Supercharge Your Excel Skills with Kutools for Excel, and Experience Efficiency Like Never Before. Kutools for Excel Offers Over 300 Advanced Features to Boost Productivity and Save Time.  Click Here to Get The Feature You Need The Most...

Description


Office Tab Brings Tabbed interface to Office, and Make Your Work Much Easier

  • Enable tabbed editing and reading in Word, Excel, PowerPoint, Publisher, Access, Visio and Project.
  • Open and create multiple documents in new tabs of the same window, rather than in new windows.
  • Increases your productivity by 50%, and reduces hundreds of mouse clicks for you every day!
Comments (12)
No ratings yet. Be the first to rate!
This comment was minimized by the moderator on the site
Help, please. This looks great, BUT when I hit the > Run button it fails with a "Compile error: Sub or Function not defined" and the code stopped at "Set rng = InputRng.Rows.Count Step xInterval +1".
This comment was minimized by the moderator on the site
Also I don't get how "Set" and "Step" could ever work together
This comment was minimized by the moderator on the site
Not sure that I will be able to help, but.. First of, there is a spacing between "C" and "ount" in "Count" when i copied your code string over to a module. Secondly, I can´t find your code anywhere else on this page, please submit the whole thing, if the problem remains.
This comment was minimized by the moderator on the site
Replace OutRng.EntireRow.Select with Intersect(OutRng.EntireRow, InputRng).Select if you want every other row within your selection
This comment was minimized by the moderator on the site
really good, thanks!
This comment was minimized by the moderator on the site
The code has one request. Does it have to select the ENTIRE ROW for each nth row? Can't it just select certain cells (range of cells) within each nth row? I don't need all the information in each row. Just certain cells of each nth row.
This comment was minimized by the moderator on the site
I made the modifications below to select 30 rows Sub EveryOtherRow() Dim rng As Range Dim InputRng As Range Dim OutRng As Range Dim xInterval As Integer xTitleId = "KutoolsforExcel" Set InputRng = Application.Selection Set InputRng = Application.InputBox("Range :", xTitleId, InputRng.Address, Type:=8) xInterval = Application.InputBox("Enter row interval", xTitleId, Type:=1) For i = 1 To InputRng.Rows.Count Step xInterval + 1 Set rng = InputRng.Cells(i, 1).Resize(, 30) 'Resize to the number of columns to select, 30 in this case If OutRng Is Nothing Then Set OutRng = rng Else Set OutRng = Application.Union(OutRng, rng) End If Next OutRng.Select 'Use OutRng.EntireRow.Select to select the entire row End Sub
This comment was minimized by the moderator on the site
Nice, thanks, this was very helpful ^_^
This comment was minimized by the moderator on the site
fanatastic. thanks a lot.it works perfect.I have more than 7000 data that need to select them with different interval.this trick was like a miracle for me.thaaaaaaaanks.
This comment was minimized by the moderator on the site
I'm trying to use the VBA macro in Excel 2010. It will only select the first nth row, not all of them in the selection. If I run it again, it will go to the next. Any idea what I'm doing wrong? Thanks!
This comment was minimized by the moderator on the site
Just saved my ass with this code thanks! My matlab decided to randomly stop working and so I had to resort to excel which I am not as familiar with as with Matlab. This def. helped. Thanks.
This comment was minimized by the moderator on the site
I need to select multiple rows and a fixed interval and move to the other sheet please answer me as soon as possible 
There are no comments posted here yet
Please leave your comments in English
Posting as Guest
×
Rate this post:
0   Characters
Suggested Locations