Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Annabelle
 
Posts: n/a
Default

I used this formula for a project status report that required 4 colors
(added cases for another spreadsheet requiring 8 colors). Right click
on the worksheet name -- select View Code -- paste this formula. The
result: when "Green" is entered in a cell, both the background and the
font is green. You can replace the verbiage in quotation with your
specific value. Remove the font section if you just want to change the
cell shading.

Private Sub Worksheet_Change(ByVal Target As Range)
Dim Num As Long
Dim rng As Range
Dim vRngInput As Variant
Set vRngInput = Intersect(Target, Range("a6:af250"))
If vRngInput Is Nothing Then Exit Sub
For Each rng In vRngInput
'Determine the color
Select Case rng.Value
Case Is = "Green": Num = 4 'green
Case Is = "Yellow": Num = 6 'yellow
Case Is = "Red": Num = 3 'red
Case Is = "Blue": Num = 11 'dark blue
End Select
'Apply the color to background
rng.Interior.ColorIndex = Num
'Determine the color
Select Case rng.Value
Case Is = "Green": Num = 4 'green
Case Is = "Yellow": Num = 6 'yellow
Case Is = "Red": Num = 3 'red
Case Is = "Blue": Num = 11 'dark blue
End Select
'Apply the color to the font
rng.Font.ColorIndex = Num
Next rng
End Sub

Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Conditional Formatting Error ddate Excel Worksheet Functions 0 May 5th 05 09:00 PM
difficulty with conditional formatting Deb Excel Discussion (Misc queries) 0 March 23rd 05 06:13 PM
conditional formatting question Deb Excel Discussion (Misc queries) 0 March 23rd 05 02:07 AM
Determine cells that drive conditional formatting? Nicolle K. Excel Discussion (Misc queries) 2 January 7th 05 01:08 AM
Conditional formatting not available in Excel BAB Excel Discussion (Misc queries) 2 January 1st 05 03:33 PM


All times are GMT +1. The time now is 12:35 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"