View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
Martijn[_2_] Martijn[_2_] is offline
external usenet poster
 
Posts: 7
Default Conditional Formatting?

Zlord,

Try this, modify it to your workbook.

Sub Macro1()

Dim cell As Range
Dim eRow As Long

eRow = Range("F2").End(xlDown).Row

For Each cell In Range("F2:F" & eRow)
Select Case cell.Value
Case 0
cell.Interior.ColorIndex = 3
Case 1
cell.Interior.ColorIndex = 6
Case 2
cell.Interior.ColorIndex = 5
Case 3
cell.Interior.ColorIndex = 8
-----
and so on
case .....
cell.Interior.ColorIndex = .....
-----

Case Else
cell.Interior.ColorIndex = xlNone
End Select
Next cell

End Sub


Good luck with it,

grtx's Martijn

"Zlord" schreef in
bericht ...

Alright, we all know how conditional formatting works.


Code:
--------------------

Range("F113:F127").Select
Selection.FormatConditions.Delete
Selection.FormatConditions.Add Type:=xlExpression,

Formula1:="=($D130=5)"
Selection.FormatConditions(1).Interior.ColorIndex = 50

--------------------


That's an example of what I want.
Doing that; The Collumn "D" stays the same; but the row increases
incrementally.
How would I code something exactly like conditional formatting in VBA?
Where it is able to use all of the excel formulas and everything.

Why I want to know -- I'm using some conditional formatting, but I need
more than the 3 built in choices.

Thanks
~Ryan


--
Zlord
------------------------------------------------------------------------
Zlord's Profile:

http://www.excelforum.com/member.php...o&userid=27519
View this thread: http://www.excelforum.com/showthread...hreadid=489279