Conditional Formatting multiple cells based on value in one cell

288enzo

Well-known Member
Joined
Feb 8, 2009
Messages
721
Office Version
  1. 2016
Platform
  1. Windows
Hi all,

So far I've been okay with conditional formatting, until now. I'm trying to format G2:P2 based on the value in P2. What I have seems to show the right values when I open up Conditional Formatting/Manager Rules, but only G is actually getting formatted.

Sub TEST()

Dim LR As Long

LR = Range("A1").CurrentRegion.Rows.Count

Range("G2", "P" & LR).FormatConditions.Add Type:=xlExpression, Formula1:="=P2=6"
With Range("G2", "P" & LR).FormatConditions(1)
.Interior.Color = 5287936
.Font.ThemeColor = xlThemeColorDark1
.Font.Bold = True
.StopIfTrue = False
End With

End Sub

Formula =P2=6
Applies to =$G$2:$P$1130
 

Excel Facts

Do you hate GETPIVOTDATA?
Prevent GETPIVOTDATA. Select inside a PivotTable. In the Analyze tab of the ribbon, open the dropown next to Options and turn it off
I believe you simply need to change formula to have absolute reference for the column as: =$P2=6

Hope that helps!

Regards,
Ken
 
Upvote 0
Solution
I believe you simply need to change formula to have absolute reference for the column as: =$P2=6

Hope that helps!

Regards,
Ken
Well, that was easy :ROFLMAO:

Thank you for the help
 
Upvote 0

Forum statistics

Threads
1,214,389
Messages
6,119,232
Members
448,879
Latest member
VanGirl

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