VBA to change cell font color and background color

dwiba

New Member
Joined
Apr 29, 2004
Messages
6
Hi,

I tried using conditional formating to have cell font color and background color change and while it works in Excel 2003 and 2007, it is not working for an Excel 2010 user. So I thought I would use VBA so it will work in any of the three versions but the code below is not working.

Based on the values calculated in two cells I want Excel to possibbly change the color of the font and background color of cells D8:D9. The ranges "none_of_above" and "sum_for_cond_check" are on a different sheet than the one I want to change the cell colors.

The code below is located on the object for the Segment Classification Sheet.

Private Sub Worksheet_Change(ByVal Target As Range)
Sheets("Segment Classification").Activate
Range("D8:D9").Select
If (Range("none_of_above") = 1 And Range("sum_for_cond_check") > 0) Then
Selection.Interior.ColorIndex = 3
Selection.Font.ColorIndex = 1
Else
End If
End Sub

Thank you in advance for your assistance.
 

Excel Facts

Why are there 1,048,576 rows in Excel?
The Excel team increased the size of the grid in 2007. There are 2^20 rows and 2^14 columns for a total of 17 billion cells.

Forum statistics

Threads
1,214,926
Messages
6,122,305
Members
449,079
Latest member
juggernaut24

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