Home » excel » excel – How to target every nth row starting from a specific row to change font colour and style?

excel – How to target every nth row starting from a specific row to change font colour and style?

Posted by: admin May 14, 2020 Leave a comment

Questions:

I’m trying to figure out how to target every 4th row starting from row 5 so that when there is text found the font colour is red and bold.

In the uploaded picture you’ll see in row 5 I have Edit Access and 4 rows down I have it there again…I was hoping to make it so anytime there’s an entry in the columns those would be red and emboldened.

Is this possible?

screenshot

How to&Answers:

Clear any existing Conditional Formatting, Select Row5 to as far down as required and HOME > Styles – Conditional Formatting, New Rule…, Use a formula to determine which cells to format and Format values where this formula is true::

=MOD(ROW()-1,4)=0

Format..., select choice of formatting OK.

Answer:

Just use a conditional formatting rule. If you don’t want to create one manually, here is the code to do so.

sub cfrEditAccess()
    with worksheets("sheet1")
        with .columns("B:AZ")
            .FormatConditions.Delete
            With .FormatConditions.Add(Type:=xlExpression, Formula1:="=$A1=""Edit Access""")
                .font.Color = 255
                .font.Bold = True
            End With
        end with
    end with
end sub