Formatting macro

Closed
ron - Jan 26, 2009 at 09:36 AM
 Helper - Feb 6, 2009 at 01:30 PM
Hi,

I have data ranging from "B8 to BZ616" all the data contains either "TRUE" or "FALSE", I do not want to use conditional formatting.
my question is I just want the word " FALSE" to change to green and leave the word TRUE as it is, could you please help me with macro code.

Regards,
Ron

2 responses

Hello,

Thank you matey!

You are doing an amazing job!

One more question !! Is there any particular book that can help me learn Macro from basic level.

Thank you!
Helper :)
1
Glad I could help.
I started with the book Excel VBA for Dummies, and then I moved on to
Excel Programming, 2nd Edition. By Jinjer Simon.
www.wiley.com
0
Private Sub ChangeColor()

Dim f As Range
Dim wrd As Boolean
wrd = "False"

For Each f In Range("B8:BZ616")
If f.Value = wrd Then
f.Select
With Selection.Font
.ColorIndex = 50
End With

End If
Next f

End Sub
0
Thank you for your Help Mate!

But it dint run through, only few rows and columns was converted to green but not the entire data,

I got runtime error 13
Type Mismatch

the error was in this line of the code

If f.Value = wrd Then

Please help!! we are almost there :)
0
Where the variable is declared in the code try "FALSE" in all uppercase instead of "False".
0
In my first example, "wrd" was declared as Boolean which returns an integer value.
Try this code instead. Hopefully, you won't get an error this time.


Private Sub ChangeColor()

Dim f As Range
Dim wrd As String
wrd = "FALSE"

For Each f In Range("B8:BZ616")
If f.Value = wrd Then
f.Select
With Selection.Font
.ColorIndex = 50
End With

End If
Next f

End Sub
0