more conditional format conditions

R

rnc

is there a way to add conditions....i need somewhere around 8 to 10 different
if statements for the spreadsheet I'm working on

maybe an add-on program?
 
R

Ron Rosenfeld

is there a way to add conditions....i need somewhere around 8 to 10 different
if statements for the spreadsheet I'm working on

maybe an add-on program?

You need to use a VBA macro and event code to do this.

But what do you mean by the "too unstable" comment about the previously
recommended solution?

In any event, here is a code snippet that I use. Perhaps you can adapt it to
your specific situation.

Or, if you can be specific about your previous criticism, I'm sure the author
of that add-in would be happy to be informed of bugs.

=======================
....

For Each c In Selection
c.NumberFormat = "0.000"

Select Case Application.WorksheetFunction.Round(c.Value, 3)
Case Is >= 1.255
c.Interior.Color = vbWhite
c.Font.Color = vbBlack
Case 1.236 To 1.254
c.Interior.Color = vbCyan
c.Font.Color = vbBlack
Case 1.215 To 1.235
c.Interior.Color = vbMagenta
c.Font.Color = vbWhite
Case 1.201 To 1.214
c.Interior.Color = vbBlue
c.Font.Color = vbWhite
Case 1.18 To 1.2
c.Interior.Color = vbYellow
c.Font.Color = vbBlack
Case 1.166 To 1.179
c.Interior.Color = vbGreen
c.Font.Color = vbBlack
Case 1.155 To 1.165
c.Interior.Color = vbRed
c.Font.Color = vbWhite
Case 1.131 To 1.154
c.Interior.Color = vbBlack
c.Font.Color = vbWhite
Case 1.11 To 1.3
c.Interior.Color = vbBlack
c.Font.Color = vbWhite
Case Else
c.Interior.ColorIndex = xlNone
c.Font.Color = vbBlack

End Select
Next c

.....
--ron
 
Top