VBA: Select rows two by two ?

YourBroLucas

New Member
Joined
Jul 11, 2022
Messages
29
Office Version
  1. 2016
Platform
  1. Windows
Hello,

I have an exported, filtered list of results (not a table) where one out of two rows (the second one) describes the first one.

Now I'd like to select these pairs of rows dynamically in order to format their borders, among other things.

I'd like, for instance, to give the impression of a table by setting a gray background color (thus one pair out of two; meaning rows 2 & 3; 6 & 7; 10 & 11...)

I've sought solutions on various forums but don't seem to be able to find dynamic and repetitive selections that do not involve the entire list.

Whoever would be kind enough to share their wisdom would have my undying gratitude ♥

You may not have the solution, but any hint might help.

⭐ Thank you in advance⭐
 
I don't see my Conditional Formatting code anywhere in your code, or in the rules of the data sample you posted.
Where did you put it?

Also, I see you are using merged cells (which sent shivers up my spine!).
I highly, HIGHLY recommend that you do NOT used merged cells!
They are probably one of the absolute worst features of Excel! They cause a ton of issues, especially for VBA.
They are so bad, many programmers here simply will not answer any questions where merged cells are involved.

Note that in situations where you are merging cells across single rows, you can use the "Center Across Selection" formatting option, which gives the same visual effect as merged cells, but without all the issues merged cells cause. See: Tom’s Tutorials For Excel: Using Center Across Selection Instead of Merging Cells – Tom Urtis

Unfortunately, there isn't a similar option for merged cells within one column down multiple rows (other than re-sizing the row height and centering the text).
 
Upvote 0

Excel Facts

How can you turn a range sideways?
Copy the range. Select a blank cell. Right-click, Paste Special, then choose Transpose.

Forum statistics

Threads
1,215,379
Messages
6,124,610
Members
449,174
Latest member
ExcelfromGermany

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