Solved

Color Row based on cell value

Posted on 2011-09-08
7
227 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:Richard Quadling
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:Richard Quadling
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
Networking for the Cloud Era

Join Microsoft and Riverbed for a discussion and demonstration of enhancements to SteelConnect:
-One-click orchestration and cloud connectivity in Azure environments
-Tight integration of SD-WAN and WAN optimization capabilities
-Scalability and resiliency equal to a data center

 
LVL 40

Expert Comment

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

Accepted Solution

by:
Richard Quadling 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:Richard Quadling
ID: 36503561
Sorry it took so long.
0

Featured Post

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

This tutorial explains how to create a series of drop-down lists that are dependent upon prior selections to guide (“force”) the user to make the correct selection and reduce data errors within Microsoft Excel. Excel 2010 was used for this tutorial;…
When you see single cell contains number and text, and you have to get any date out of it seems like cracking our heads.
This Micro Tutorial will demonstrate on a Mac how to change the sort order for chart legend values and decrpyt the intimidating chart menu.
This Micro Tutorial will demonstrate how to use a scrolling table in Microsoft Excel using the INDEX function.

830 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