LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #9   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,494
Default Fill Color

not sure if you have any other code or what you do to change your data, but if
you paste this on the worksheet code page, it may work for you

in the vb editor, right click the worksheet and click view code, then paste it.


Private Sub Worksheet_Change(ByVal Target As Range)
Dim ws As Worksheet
Dim i As Long
Dim rng As Range
Dim icolor As Long
Dim lastrow As Long
Set ws = Worksheets("Sheet1")
lastrow = ws.Cells(Rows.Count, "M").End(xlUp).Row

For i = 2 To lastrow
With ws.Range("M" & i)
Select Case UCase(.Value)
Case "BELOW"
icolor = 3
Case "AT RISK"
icolor = 6
Case "MEETS"
icolor = 4
Case "EXCEEDS"
icolor = 5
Case Else
icolor = 0
End Select
.Interior.ColorIndex = icolor
End With
Next
End Sub

--


Gary

"Walt Herman" wrote in message
...
would i paste this into a worksheet change event to effect the automatic
apsects of it? can you help? sorry....

"Gary Keramidas" wrote:

you can give this a try. change the worksheet name and the column letter. you
may also want to change the shades of the colors.

Sub Var_Colors()
Dim ws As Worksheet
Dim i As Long
Dim icolor As Long
Dim lastrow As Long
Set ws = Worksheets("Sheet1")
lastrow = ws.Cells(Rows.Count, "C").End(xlUp).Row

For i = 2 To lastrow
With ws.Range("C" & lastrow)
Select Case UCase(.Value)
Case "BELOW"
icolor = 3
Case "AT RISK"
icolor = 6
Case "MEETS"
icolor = 4
Case "EXCEEDS"
icolor = 5
End Select
.Interior.ColorIndex = icolor
End With
Next
End Sub


--


Gary

"Walt Herman" wrote in message
...
Ok, I honestly spent a good half hour trying to find a posting which
approximated what I wanted to do and have run out of patience. Can someone
please help me?

I have a variance report with a column that evaluates the results of each
variance. There are 4 distinct values: Below, Meets, Exceeds, At Risk.

I need the fill color for each of these values to change automatically as
the evaluation changes. The rules for the fill color a

"Below" should be RED, "At Risk" should be YELLOW, "Meets" should be GREEN,
and "Exceeds" should be BLUE.

I am sure there needs to be a case statement but really seem to be
challenged in writing the code. I appreciate any help you can provide.

Regards,

Walt






 
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
color fill button is not adding color to my spread sheet mitchnmd Excel Worksheet Functions 1 September 26th 07 04:36 PM
change fill color of a range of cells based on color of a cell? DarMelNel Excel Programming 0 March 2nd 06 06:35 PM
My fill color and font color do not work in Excel Std Edition 2003 chapstick Excel Discussion (Misc queries) 1 September 11th 05 08:48 PM
Excel 2003 will not display color fonts or color fill cells DaveC Excel Worksheet Functions 1 April 11th 05 04:38 PM
My excel 2003 wont let me fill cells with color or color the tabs. trizog New Users to Excel 2 February 22nd 05 06:43 PM


All times are GMT +1. The time now is 11:11 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"