VBA to Conditional Format based on cell text

Jefe187

New Member
Joined
Oct 24, 2015
Messages
13
I know this is an easy solution using conditional format, but rows can change daily in my spreadsheet, columns however will stay the same. If the word "yes" is in column "J" then I would like to format that cell plus the next 6 to right. Example: J6 contains yes, then J6:P6 will fill blue, white lettering, bold. Here is what I have thus far.

Dim rngA As Range
Dim cell As Range

Set rngA = Range("J1", Range("J10000").End(xlUp))
For Each cell In rngA
If cell.Value = "Yes" Then
Range("J:P").Select
With Selection.Interior
.PatternColorIndex = xlAutomatic
.ThemeColor = xlThemeColorLight2
.TintAndShade = 0
.PatternTintAndShade = 0
End With
With Selection.Font
.ThemeColor = xlThemeColorDark1
.TintAndShade = 0
End With
Selection.Font.Bold = True
End If
Next cell

End Sub
 

Excel Facts

When they said...
When they said you are going to "Excel at life", they meant you "will be doing Excel your whole life".
A bit cumbersome, but I got it to work.

LastRow = Cells(Rows.Count, "J").End(xlUp).Row


For i = LastRow To 1 Step -1
If Range("J" & i).Value = "Yes" Then
Range("J" & i).Columns("A:G").Select
With Selection.Interior
.PatternColorIndex = xlAutomatic
.ThemeColor = xlThemeColorLight2
.TintAndShade = 0
.PatternTintAndShade = 0
End With
With Selection.Font
.ThemeColor = xlThemeColorDark1
.TintAndShade = 0
End With
Selection.Font.Bold = True
End If
Next i




End Sub
 
Upvote 0

Forum statistics

Threads
1,223,228
Messages
6,170,871
Members
452,363
Latest member
merico17

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