View Single Post
  #6   Report Post  
Posted to microsoft.public.excel.misc
Lola Lola is offline
external usenet poster
 
Posts: 5
Default if statement to shade cells (more than 3 conditions)


Hi:
First, thank you for your posting, they are very helpful.
I am having kind of the same problem than Mo2 with the difference that the
cells that need to shade are in different table, but within the same
worksheet.
This is an example of what I am trying to do:

If cell value is = -0.1 but <= -0.150 then color the cell in green
I do have formulas that will calculate the different values, lets say:
A1-B1 = -0.125

Please note: I only want to create a macro that change color once the
results are in. I do notwant to include the formulas. I created a botton to
have the macro assign to it.

Thank you so much for any suggestions you might have

"JE McGimpsey" wrote:

One way:

Put this in your worksheet code module (right-click the worksheet tab
and choose View Code):

Private Sub Worksheet_Change(ByVal Target As Excel.Range)
With Range("E4")
If Not Intersect(Target.Cells, .Cells) Then
Select Case .Value
Case 2
.Interior.ColorIndex = 5
Case 3
.Interior.ColorIndex = 6
Case 4
.Interior.ColorIndex = 4
Case 5
.Interior.ColorIndex = 53
Case 6
.Interior.ColorIndex = 13
Case Else
.Interior.ColorIndex = xlColorIndexNone
End Select
End If
End WIth
End Sub



In article ,
Mo2 wrote:

If A4= 2, shade E4 blue
If A4= 3, shade E4 yellow
If A4=4, shade E4 brown
If A4=5, shade E4 orange
If A4=6, shade E4 purple

can't use conditional formatting (there is more than 3 conditions)

can anyone help?

P.S. i know nothing about visual basic