Select nth rows

Hatye

Board Regular
Joined
Jan 11, 2010
Messages
143
Hi,

I would like to select the two first rows (cells) to set white font color and not the third (to keep black font color). This should be a loop to select enitre list.
How should I do that?

Code:
Sheets("PunktavvikHist").Range("BI58").Select


         Do While ActiveCell.Value <> ""
             With Selection.Font
                .ThemeColor = xlThemeColorDark1
                .TintAndShade = 0
            End With
             ActiveCell.Offset(1, 0).Select
         Loop
 

Excel Facts

Can Excel fill bagel flavors?
You can teach Excel a new custom list. Type the list in cells, File, Options, Advanced, Edit Custom Lists, Import, OK
You don't need VBA to do this, you can use Conditional Formatting.

All you need to do is select the range of cells you wish to apply this to, go to Conditional Formatting, select the Formula option, and enter the following formula:
=OR(MOD(ROW(),3)=1,MOD(ROW(),3)=2)
and then select the white font formatting option.

Note, depending on what the first row number you want to apply this to is, you many need to adjust your formula slightly, to this:
=OR(MOD(ROW(),3)=0,MOD(ROW(),3)=1)
or this:
=OR(MOD(ROW(),3)=2,MOD(ROW(),3)=0)
 
Upvote 0

Forum statistics

Threads
1,226,730
Messages
6,192,699
Members
453,747
Latest member
tylerhyatt04

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