Color Row based on cell value

excel 2003
vba routine needed


I need to Loop through all rows
Look in Column A: If a value is  "CS_Project_Number"
Then color that row  "Gray" from  Column A:J

Thanks
fordraiders
LVL 3
FordraidersAsked:
Who is Participating?

[Webinar] Streamline your web hosting managementRegister Today

x
 
Richard QuadlingConnect With a Mentor Senior Software DeveloperCommented:
Is this what you wanted?

Option Explicit

Sub Q27297739()
Dim o_Row As Range

For Each o_Row In ActiveSheet.UsedRange.Rows
    With o_Row
        If .Cells(1, 1).Value = "CS_Project_Number" Then
            With .Columns("A:J").Interior
                .Color = RGB(255, 127, 127)
                .Pattern = xlSolid
            End With
        Else
            .Columns("A:J").Interior.ColorIndex = xlNone
        End If
    End With
Next o_Row
End Sub

Open in new window

0
 
Richard QuadlingSenior Software DeveloperCommented:
Does this fit your needs?
Option Explicit

Sub Q27297739()
With ActiveSheet
    If .Cells(1, 1).Value = "CS_Project_Number" Then
        With .Columns("A:J").Interior
            .ColorIndex = 40
            .Pattern = xlSolid
        End With
    End If
End With
End Sub

Open in new window

0
 
Richard QuadlingSenior Software DeveloperCommented:
ColorIndex doesn't have all the colours, but Color can be set using RGB.

Option Explicit

Sub Q27297739()
With ActiveSheet
    If .Cells(1, 1).Value = "CS_Project_Number" Then
        With .Columns("A:J").Interior
            .Color = RGB(127, 127, 127)
            .Pattern = xlSolid
        End With
    End If
End With
End Sub

Open in new window

0
Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

 
FordraidersAuthor Commented:
both solutions color every row  not just the row containing  "CS_Project_Number"

0
 
Richard QuadlingSenior Software DeveloperCommented:
Can you give me an example spreadsheet as I've misunderstood your structure.
0
 
FordraidersAuthor Commented:
Perfect Thanks !
0
 
Richard QuadlingSenior Software DeveloperCommented:
Sorry it took so long.
0
All Courses

From novice to tech pro — start learning today.