I have Range object called DestinationRange which references range B3:H63
I want to apply the following two conditional formatting rules using Excel VBA code dynamically (the range can change):
- If Cell column D is blank, no formatting should be applied (Need to use Stop If True there)
- If Value in Cell of column E is lesser than value in cell of column F, that whole row should have green background.
I tried using recording but it’s not recording properly. How can I perform this conditional formatting using VBA?
This will get you to an answer for your simple case, but can you expand on how you’ll know which columns will need to be compared (B and C in this case) and what the initial range (
A1:D5in this case) will be? Then I can try to provide a more complete answer.Note: this is tested in Excel 2010.
Edit: Updated code based on comments.