PDA

View Full Version : excel vba change cell color based on a number value in a range



bjason
03-08-2018, 09:36 AM
I need to change the cell color, in a range, to red if the cell contains a negative integer. I am relatively new to VBA. I have bee trying an if then function but I have been unsuccessful.

SamT
03-08-2018, 09:47 AM
PseudoCode, Needs Expansion
Dim Cel As Range

For Ech Cel in SpecifiedRange
If Cel < 0 Then Cel.Interior.ColorIndex = 3
Next

bjason
03-08-2018, 10:27 AM
Thank you for your help SamT. That worked perfectly

SamT
03-08-2018, 10:35 AM
You're Welcome

Thanks for the Thanks. Makes my day :cloud9: