I'm looking for a slightly better way of doing the following...
Sub FalseTrueTest2() Dim cl As Range For Each cl In Range("A2:A" & Range("A" & Rows.Count).End(xlUp).Row) Select Case cl.Value Case Is = "True" cl.Style = "Good" Case Is = "False" cl.Style = "Bad" End Select Next End Sub
Last edited by Hyflex; 02-13-2012 at 10:12 AM.
Hyflex,
I would recommend conditional formatting instead of VBA. highlight column A and create two conditional format formulas:
For the Good style, use this formula: =AND($A1<>"",$A1="True")
For the Bad style, use this formula: =AND($A1<>"",$A1="False")
Last edited by tigeravatar; 02-13-2012 at 10:41 AM.
Hope that helps,
~tigeravatar
Forum Rules: How to use code tags, mark a thread solved, and keep yourself out of trouble
I do see in your thread title that it says "(Not Conditional)". If it has to be VBA, I'd recommend using autofilter for this operation:
Sub FalseTrueTest2() On Error Resume Next Application.ScreenUpdating = False With Range("A1", Cells(Rows.Count, "A").End(xlUp)) .AutoFilter 1, "True" .Offset(1).Resize(.Rows.Count - 1).SpecialCells(xlCellTypeVisible).Style = "Good" .AutoFilter 1, "False" .Offset(1).Resize(.Rows.Count - 1).SpecialCells(xlCellTypeVisible).Style = "Bad" .AutoFilter End With Application.ScreenUpdating = True End Sub
Hope that helps,
~tigeravatar
Forum Rules: How to use code tags, mark a thread solved, and keep yourself out of trouble
There are currently 1 users browsing this thread. (0 members and 1 guests)
Bookmarks