Conditional Formatting VBA help

ashley1984

New Member
Joined
Mar 31, 2018
Messages
32
Office Version
  1. 365
Platform
  1. Windows
Hi All,

I’m trying to apply conditional formatting to a table using VBA. I’ve currently got this set up as conditional formatting through Excel but the file goes off to users who change/delete the conditional formatting, so I want a macro to reset the conditional formatting once I get the file back.

I want the £ Sales YOY % Change & Vol YoY % Change rows to be green or red if they are above or below 0

The data table is below
DataTable.PNG


and the code I'm having trouble with is:

Sub ConditionalFormatTable

If Cells("D5:L5").Value < 0 Then
Cells("D5:L5").Interior.Color = RGB(255, 199, 206)
Else
Cells("D5:L5").Interior.Color = RGB(198, 239, 206)
End If

End Sub
 

Excel Facts

Convert text numbers to real numbers
Select a column containing text numbers. Press Alt+D E F to quickly convert text to numbers. Faster than "Convert to Number"
You cannot check an entire range of values like that, you will need to loop through the range.
 
Upvote 0

Forum statistics

Threads
1,215,771
Messages
6,126,798
Members
449,337
Latest member
BBV123

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