Fill colour, font colour

nickolm

Registered User.
Local time
Today, 18:28
Joined
Dec 30, 2008
Messages
11
Hello,

Still quite new to excel vba. I am trying to get something that will look down column A starting at A10 and look at each cell contents. If the value is say 5 then colour font yellow, 4 colour it green etc. Then interrogate next cell and repeat. When it gets to cell A30 it stops. It them does the same thing but using fill colour using column B.

Can somebody please help with the loop, if and select case and so on... been a long time since i did this

Thanks
Matthew
 
Last edited:
Hi, Mathew,

why not use the values for the ColorIndex? This oine is for Columns A to C but just the font, for the fill colour please use Interior instead of Font

Code:
Sub ColorMe()
Dim lngCounter As Long
Dim lngCol As Long

For lngCol = 1 To 3
    For lngCounter = 10 To 30
        With Cells(lngCounter, lngCol)
            Select Case .Value
                Case 5
                    .Font.ColorIndex = 6
                Case 4
                    .Font.ColorIndex = 4
                Case 3
                    .Font.ColorIndex = 5
                Case Else
            End Select
        End With
    Next lngCounter
Next lngCol
End Sub
Ciao,
Holger
 
Thanks

It works!

Cheers for taking the time with something so trivial but, for my purposes, so helpful.

Matthew
 

Users who are viewing this thread

Back
Top Bottom