Apr 9, 2020

How to select every nth cell in a column

I have a list of websites, and I want to use a macro or formula to select every 5th cell.
Right now, when I want to open these websites, I have to hold down CTRL and then click every 5th website to select them and then when I'm done, press ALT + ENTER to open them all.
Is there a way to automate the selection part of cells? 
Thanks!
Locked
Informational notification.
This question is locked and replying has been disabled.
Community content may not be verified or up-to-date. Learn more.
Recommended Answer
Apr 9, 2020
Hi, Djordje Blagojevic,
 
I'll do it as below.
 
Test Data in B2:B.
 
Filter Column B (select column B ->Data menu -> Create a filter).
 
Then use the below formula.
 
=mod(row(A1),5)=0
 
It filters every 5th row.


Select the links and hit Alt+Enter.
 
Hope this helps?
 
Best,
 
Prashanth KV
Last edited Apr 9, 2020
Original Poster Djordje Blagojevic marked this as an answer
Helpful?
Recommended Answer
Apr 10, 2020
Hi, Djordje Blagojevic,

You can use any cell reference like B1, C1, D1... as the below formulas will just return the same row number.

=row(A1)
=row(B1)
=row(C1)

So if the data that you want to filter is in column E, you can use the same formula, i.e. =mod(row(A1),5)=0. Change 5 to 10, to filter every 10th row.

The formula,=mod(row(A1),5)=0,  works like this automatically in each row.

=mod(1,5)=0
=mod(2,5)=0
=mod(3,5)=0
=mod(4,5)=0
=mod(5,5)=0

The last formula in the fifth row would return a TRUE and the other four formulas will return FALSE.

As you may know, the MOD function returns the result of the modulo operator, the remainder after a division operation.

 See the formula in the next 5 rows.

=mod(6,5)=0
=mod(7,5)=0
=mod(8,5)=0
=mod(9,5)=0
=mod(10,5)=0

Here again, only the 5th formula in row number 10 would return TRUE. So the filter filters the rows wherever TRUE appears in the test.

Refer: 


Best,

Prashanth KV
Last edited Apr 10, 2020
Original Poster Djordje Blagojevic marked this as an answer
Helpful?
All Replies (4)
Recommended Answer
Apr 9, 2020
Hi, Djordje Blagojevic,
 
I'll do it as below.
 
Test Data in B2:B.
 
Filter Column B (select column B ->Data menu -> Create a filter).
 
Then use the below formula.
 
=mod(row(A1),5)=0
 
It filters every 5th row.


Select the links and hit Alt+Enter.
 
Hope this helps?
 
Best,
 
Prashanth KV
Last edited Apr 9, 2020
Original Poster Djordje Blagojevic marked this as an answer
Apr 9, 2020
Thank you, Prashanth KV, it works exactly as I wanted.

Could you just please explain the formula in more detail? 
I don't understand why we use A1 in the formula if the data is in B column?

So if my data that I wanna filter is in column E, i have to write =mod(row(D1)5)=0, etc
Recommended Answer
Apr 10, 2020
Hi, Djordje Blagojevic,

You can use any cell reference like B1, C1, D1... as the below formulas will just return the same row number.

=row(A1)
=row(B1)
=row(C1)

So if the data that you want to filter is in column E, you can use the same formula, i.e. =mod(row(A1),5)=0. Change 5 to 10, to filter every 10th row.

The formula,=mod(row(A1),5)=0,  works like this automatically in each row.

=mod(1,5)=0
=mod(2,5)=0
=mod(3,5)=0
=mod(4,5)=0
=mod(5,5)=0

The last formula in the fifth row would return a TRUE and the other four formulas will return FALSE.

As you may know, the MOD function returns the result of the modulo operator, the remainder after a division operation.

 See the formula in the next 5 rows.

=mod(6,5)=0
=mod(7,5)=0
=mod(8,5)=0
=mod(9,5)=0
=mod(10,5)=0

Here again, only the 5th formula in row number 10 would return TRUE. So the filter filters the rows wherever TRUE appears in the test.

Refer: 


Best,

Prashanth KV
Last edited Apr 10, 2020
Original Poster Djordje Blagojevic marked this as an answer
Apr 10, 2020
Thank you so much, Prashanth KV
false
17448466522281486679
true
Search Help Center
true
true
true
true
true
35
Search
Clear search
Close search
Main menu
false
false