Go Premium for a chance to win a PS4. Enter to Win

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 417
  • Last Modified:

excel trick, if "good" set whole row green

We have a status line in excel and the boss is spending a lot of time formatting and reformatting.
status is a columb, lets call it   "H"
If the status = good, format whole row green
If the status = working, format whole row yellow
If the status = blank, format whole row white.

thank you




0
TIMFOX123
Asked:
TIMFOX123
  • 8
  • 6
  • 5
  • +2
2 Solutions
 
rspahitzCommented:
this is a classic case for Conditional Formatting.

If using Excel 2007/2010,
So first select the row where you want this to apply.
Then Home tab, Styles group box, choose Conditional Formatting
There are a few options there but use New Rule.
Then pick the last one: Use a formula

Enter the formula (assuming applied to row 1): H1="good"
Then set the format (green background)

Add another rule for yellow.

0
 
barry houdiniCommented:
Select your whole range and then use this formula in conditional formatting

=$H1="good"

Set required format and repeat for other words

Note $ in formula - if range start on row other than 1 then change as appropriate

Regards, barry
0
 
gtglonerCommented:
Have a look at the file below. In row 1, type:

good

in any cell and watch the background change. This is an example of use of conditional formatting. If you want to see how this was achieved, select one of the cells in row 1 and click Format-Conditional Formatting in the menu bar at the top of the screen. You will see the 3 different colours depending on the condition.
Book1.xls
0
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.

 
barry houdiniCommented:
Note that for blank  condition use

=$H1=""

$ sign ensures that whole row is formatted
0
 
SiddharthRoutCommented:
This is via VBA. Please paste it in the worksheet selection event.

Private Sub Worksheet_Change(ByVal Target As Range)
    Application.EnableEvents = False
    If Not Intersect(Target, Range("H:H")) Is Nothing Then
        Select Case UCase(Target.Value)
        Case "GOOD"
            Rows(Target.Row).Interior.ColorIndex = 4
        Case "WORKING"
            Rows(Target.Row).Interior.ColorIndex = 6
        Case Else
            Rows(Target.Row).Interior.ColorIndex = xlAutomatic
        End Select
    End If
    Application.EnableEvents = True
End Sub

Open in new window


Sid
0
 
TIMFOX123Author Commented:
Cool except I can make this work for one cell
if cell =  good then format whole row green.

Now, how do I "copy" this conditional formating to many many cells ?

0
 
rspahitzCommented:
Copy the cell (Ctrl C) with the conditional formatting
Select the row
Right-click and in the paste section, choose formatting (with the % and paintbrush)
0
 
TIMFOX123Author Commented:
tried this several time but I can not get it to format the other rows

Copy the cell (Ctrl C) with the conditional formatting
Select the row
Right-click and in the paste section, choose formatting (with the % and paintbrush)
0
 
SiddharthRoutCommented:
If a vba code interests you then do have a look at the code that I posted.

Sid
0
 
TIMFOX123Author Commented:
It is intresting, I just do not know how to add it :)
Tell me more.
0
 
TIMFOX123Author Commented:
oh excel 2007
0
 
rspahitzCommented:
When you copy, make sure the active cell is the one with the conditional formatting (the =$H1="good")

However, I find it easier to just select the whole row then apply the conditional formatting formula.
Also, make sure you apply the green formatting :)
0
 
TIMFOX123Author Commented:
If I could get it done with out vba, I would prefer that.
I just get it to work for just one column.
0
 
SiddharthRoutCommented:
Sure.

Press Alt+F11 from the worksheet to open the VBE Editor and then paste the code as in the snapshot :)

Hope this helps.

Sid
Untitled.jpg
0
 
SiddharthRoutCommented:
If I could get it done with out vba, I would prefer that.
I just get it to work for just one column.

In that case follow what Barry says :)

Sid
0
 
barry houdiniCommented:
Did you use the $ in the formula?
0
 
TIMFOX123Author Commented:
I put that vm macro in somehow badly.  

I am sure it works, I need to undo what I have done :)

any ideas ?
0
 
SiddharthRoutCommented:
Upload your file here. I will remove it :)

Sid
0
 
barry houdiniCommented:
See attached - example

this uses the method I suggested to highlight the whole row (or at least the part I selected). If you can't make it work I can talk you through the steps.

regards, barry

PS which Excel version are you using?
26815396.xls
0
 
SiddharthRoutCommented:
I would suggest that you upload the file here so that I or Barry can remove the macro and then you can follow Barry which will be very easy :)

Sid
0
 
rspahitzCommented:
Let's try once more...first, revert to a saved copy.

On the sheet where you want this stuff to apply, select the whole page (Ctrl+A)
Proceed to Conditional Formatting, add new rule, enter a formula, as explained previously.

enter this formula:

=INDIRECT("H"&ROW())="good"
then format to show a green background.

then add another rule to the above:

=INDIRECT("H"&ROW())="working"
then format to show a yellow background.

that's it!
Note that applying all of these conditional formatting settings to the whole workbook will cause it to be a big file so you may want to select just a few rows where it will apply instead of the entire sheet.
0
 
barry houdiniCommented:
....but you don't need INDIRECT or ROW() functions, you don't need any functions......

as I suggested previously this formula is sufficient assuming you are starting at row 1

=$H1="good"

If you want to start at a different row then you can adjust the formula to that row, e.g. if you want to format all columns from A to Z from row 4 to row 100 then you should select that range, A4:Z100 [ you can select that range easily by just typing it into the box above A1 and pressing ENTER]

Now you just apply the formula that applies to the top row of the range

=$H4="good"

by using the $ you are "fixing" the column part of the cell reference. This means that all columns in the range will reference column H....but the rows will adjust so cells in row 5 or row 20 will use the H cell in the current row.

regards, barry
0
 
rspahitzCommented:
agreed...i think barry should get the points
not sure why it wasn't working for timfox...maybe upload a file minus important data and we can see if there's something strange about it
0
 
TIMFOX123Author Commented:
All:

You all are my heros !!  great job.  

the reason the non vbscript was not working for me is I had to triple read the instuctions.  you need to highlight the cells you want conditionally formatted before you go into the wizzard and write the macro.  As usuall it was user error   Pbkac  ( problem between keyboard and chair ).
thank you alll
0
 
TIMFOX123Author Commented:
BTW barry was the first person to tell me what I was missing  :)
0

Featured Post

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

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.

  • 8
  • 6
  • 5
  • +2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now