Solved

Color Row based on cell value

Posted on 2011-09-08
7
200 Views
Last Modified: 2012-05-12
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
0
Comment
Question by:fordraiders
  • 5
  • 2
7 Comments
 
LVL 40

Expert Comment

by:RQuadling
Comment Utility
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
 
LVL 40

Expert Comment

by:RQuadling
Comment Utility
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
 
LVL 3

Author Comment

by:fordraiders
Comment Utility
both solutions color every row  not just the row containing  "CS_Project_Number"

0
How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

 
LVL 40

Expert Comment

by:RQuadling
Comment Utility
Can you give me an example spreadsheet as I've misunderstood your structure.
0
 
LVL 40

Accepted Solution

by:
RQuadling earned 500 total points
Comment Utility
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
 
LVL 3

Author Closing Comment

by:fordraiders
Comment Utility
Perfect Thanks !
0
 
LVL 40

Expert Comment

by:RQuadling
Comment Utility
Sorry it took so long.
0

Featured Post

Highfive Gives IT Their Time Back

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

A little background as to how I came to I design this code: Around 5 years ago I designed an add-in that formatted Excel files to a corporate standard, applying different cell colours and font type depending on whether the cells contained inputs,…
Dealing with unintended Excel Active-X resizing quirks (VBA code simulates "self correction") David Miller (dlmille) Intro Not everyone is a fan of Active-X controls in spreadsheets (as opposed to the UserForm approach, the older Form controls …
This Micro Tutorial demonstrate the bugs in Microsoft Excel for Mac with Pivot Charts.
This Micro Tutorial will demonstrate in Google Sheets how to use the HYPERLINK function to create live links inside your spreadsheet.

772 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now