Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Color Row based on cell value

Posted on 2011-09-08
7
Medium Priority
?
247 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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
Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

 
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 2000 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

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

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

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.
Access developers frequently have requirements to interact with Excel (import from or output to) in their applications.  You might be able to accomplish this with the TransferSpreadsheet and OutputTo methods, but in this series of articles I will di…
Graphs within dashboards are meant to be dynamic, representing data from a period of time that will change each time the dashboard is updated with new data. Rather than update each graph to point to a different set within a static set of data, t…
This Micro Tutorial will demonstrate how to use a scrolling table in Microsoft Excel using the INDEX function.

705 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