VBA help make font colour red in the entire column

motilulla

Well-known Member
Joined
Feb 13, 2008
Messages
2,362
Office Version
  1. 2010
Hello,

My data are in range C2:J51 that has always fix value in each column 5, 9 and G

I need VBA help; I have data range C2:J51 total 8 columns out of 8 if any entire column has 1 or 2 values (not all 3) make the font colour red.

In this given example there are 5 columns in which there are 1 or 2 vale...
Column C has 2 values G&9 colour this column font in red.
Column E has 1 value, which is 5, colours this column font in red.
Column G has 2 values 5&G colour this column font in red.
Column H has 1 value, which is 9, colours this column font in red.
Column I has 2 values G&9 colour this column font in red.

Rest 3 columns D, F J has all 3 values 5, 9 and G so far leave it font colour black

For more detail the image is attached.

*ABCDEFGHIJKL
1Data1Data2Data3Data4Data5Data6Data7Data8
2G55559GG
3G555599G
4G555599G
5G555599G
6G55559GG
7G555599G
8G555G99G
9G555599G
109555599G
119555599G
12GG55599G
13GG5559GG
149G5559G9
15G95559G9
16G955G9G5
17995559G5
1899555995
1999555995
209955599G
21G55GG99G
22G55G59G9
23G55G5999
24G55G5995
25G55G5995
26955G5995
27GG5G5995
28GG5G5995
299G5G599G
309G5GG99G
31G95G59GG
32995G59GG
33G55959G9
34G55959G9
35955959G9
36955959G9
37GG5959G5
389G5959G5
39G95959G5
40995959G5
41G555G99G
42G555G99G
43G555G999
449555G999
459555G9G5
46GG55G995
47GG55G995
48GG55G995
499G55G995
50G955G99G
519955G99G
52
53
54

Thank you all.

I am using Excel 2000

Regards,
Moti
 

Attachments

  • 2 Values Entire Column Red Fonts.png
    2 Values Entire Column Red Fonts.png
    39.3 KB · Views: 6

Excel Facts

How can you automate Excel?
Press Alt+F11 from Windows Excel to open the Visual Basic for Applications (VBA) editor.
Try this:
VBA Code:
Sub a1181663b()
Dim i As Long, x
Dim c As Range
For i = 3 To 10
    With Range(Cells(2, i), Cells(51, i))
        For Each x In Array("G", 5, 9)
            Set c = .Find(What:=x, LookIn:=xlValues, LookAt:=xlWhole, SearchOrder:=xlByRows, _
            SearchDirection:=xlNext, MatchCase:=False, SearchFormat:=False)
            If c Is Nothing Then .Font.Color = vbRed: Exit For
        Next
    End With
Next

End Sub
 
Upvote 0
Solution
Try this:
VBA Code:
Sub a1181663b()
Dim i As Long, x
Dim c As Range
For i = 3 To 10
    With Range(Cells(2, i), Cells(51, i))
        For Each x In Array("G", 5, 9)
            Set c = .Find(What:=x, LookIn:=xlValues, LookAt:=xlWhole, SearchOrder:=xlByRows, _
            SearchDirection:=xlNext, MatchCase:=False, SearchFormat:=False)
            If c Is Nothing Then .Font.Color = vbRed: Exit For
        Next
    End With
Next

End Sub
Akuini, macro did the job as request fantastic! (y)

Thank you so much for your help and time you took for building a macro solution.

Good Luck

Kind Regards,
Moti :)
 
Upvote 0

Forum statistics

Threads
1,215,425
Messages
6,124,822
Members
449,190
Latest member
rscraig11

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top