TheRedCardinal
Active Member
- Joined
- Jul 11, 2019
- Messages
- 250
- Office Version
- 365
- 2021
- Platform
- Windows
Hi all,
I have a requirement to add conditional formatting to a whole table, such that if the value in a specified column in negative, the whole row is highlighted.
I have come up against two blocks:
Here is the code I've used:
It has populated the conditional formatting correctly:
But it doesn't take effect in the table itself.
Also, I have hard coded column I, but it might move - can I make the reference dynamic?
Thanks!
I have a requirement to add conditional formatting to a whole table, such that if the value in a specified column in negative, the whole row is highlighted.
I have come up against two blocks:
- My code doesn't actually work!
- I can't work out how to make it factor in that the relevant column might move
Here is the code I've used:
VBA Code:
Set FormRange = WS2.ListObjects(1).DataBodyRange
With FormRange.FormatConditions.Add(Type:=xlExpression, Formula1:="$I2<0")
.Interior.Color = 65535
.StopIfTrue = False
End With
It has populated the conditional formatting correctly:
But it doesn't take effect in the table itself.
Also, I have hard coded column I, but it might move - can I make the reference dynamic?
Thanks!