Solved

Color Row based on cell value

Posted on 2011-09-08
7
212 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
ID: 36503285
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
ID: 36503299
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
ID: 36503390
both solutions color every row  not just the row containing  "CS_Project_Number"

0
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 
LVL 40

Expert Comment

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

Accepted Solution

by:
RQuadling earned 500 total points
ID: 36503463
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
ID: 36503504
Perfect Thanks !
0
 
LVL 40

Expert Comment

by:RQuadling
ID: 36503561
Sorry it took so long.
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
FormulaArray VBA Issue 6 18
Update As Well As Add 6 40
Automating Excel Weekly Report 13 64
In this macro, I would like to be prompted for a folder. 7 28
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,…
Freeze panes is an option within all variants of Excel to enable parts of a sheet to remain stationary when the cursor is in another part of the sheet. This is a very useful feature which is overlooked or under used.
The viewer will learn how to use the =DISCRINV command to create a discrete random variable, use this command to model a set of probabilities and outcomes in a Monte Carlo simulation, and learn how to find the standard deviation of a set of probabil…
This Micro Tutorial will demonstrate in Microsoft Excel how to add style and sexy appeal to horizontal bar charts.

863 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

25 Experts available now in Live!

Get 1:1 Help Now