Formatting macro

[Closed]
Report
-
 Helper -
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 replies

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
Thank you

A few words of thanks would be greatly appreciated. Add comment

CCM 2942 users have said thank you to us this month

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
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
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 :)
Where the variable is declared in the code try "FALSE" in all uppercase instead of "False".
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