Solved

Excel: Format cell based on contents of other cell

Posted on 2012-03-12
8
341 Views
Last Modified: 2012-03-12
Hi Experts,

In Excel 2003, what's the best way to format a range of cells (e.g. make the text green) based on the contents of a different cell?  I know I can use Conditional Formatting to format a cell based on its contents, but this is different.

For example, how could I make the text in A2 through to A10 become green if A1 contains "Yes".

Thanks.
Tel2
0
Comment
Question by:tel2
  • 4
  • 2
  • 2
8 Comments
 
LVL 14

Accepted Solution

by:
Zack Barresse earned 500 total points
ID: 37712599
Hi there,

You still use Conditional Formatting.  Just use the formula option and, with A2:A10 selected** use this  formula:

=$A$1="Yes"

** The important part of using referencing in CF is what cell is the active cell.  In this example it doesn't matter, but if you were using any portion of releative (vs absolute) referencing, it would be largely important.  But this will get what you need.

Take care!
Zack Barresse
0
 
LVL 33

Expert Comment

by:Norie
ID: 37712610
Use conditional formatting with a formula.

1 Select A2:A10.

2 Goto Conditional Formatting.

3 Select Use a formula to determine which cells to format.*

4 Enter this formula

=$A1="Yes"

5 Format as required.

* That's for 2010, I think it earlier version it's Formula is you select.
0
 
LVL 14

Expert Comment

by:Zack Barresse
ID: 37712622
@imnorie: You would need to have absolute referencing to the row in this case.  Locking down the column, if the column doesn't move with the range, wouldn't matter at all, but the row would, otherwise A2 would look at A1, A3 would look at A2, A4 would look at A3, etc, etc.

Regards,
Zack Barresse
0
Gigs: Get Your Project Delivered by an Expert

Select from freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely and get projects done right.

 
LVL 33

Expert Comment

by:Norie
ID: 37712631
Sorry, my mistake.

Got row and column mixed up.
0
 
LVL 12

Author Comment

by:tel2
ID: 37712735
Thank you guys!  It works, and thanks for the explanation re absolute references, firefytr.

If you'll forgive the slight scope creap, now that I've applied this CF to A2:A10, how can I copy that CF to B2:Z10 (i.e. 25 similar column ranges whose formatting will depend on the values of B1 to Z1), without copying other formatting and cell contents (e.g. borders?  I know I can use the Format Painter, but that seems to copy borders, etc, too.  I also know that if I Copy, I can Paste Special with "All except borders", but still replaces formulas and values.

This is not very important, and I will award points even without this, but it would be good to know whether you know of an easy way or not.

Or shall I open another question for that?
0
 
LVL 14

Expert Comment

by:Zack Barresse
ID: 37712747
It's no problem.  This is all related.  I would encourage you, in future postings, to put all relevant information in your posts though.  :)

You can copy and paste formats (Copy, PasteSpecial, Formats) as you noted, but CF will paste along with the other formats as well.  If you were using 2010 you would be able to do this easily, but not with 2003.  But with such a simple CF, I would just add it to that range.  Remember, if you want the column to change, you must leave that as relative.  So if you selected B2:Z10, and still assuming you wanted to look at B1 for a "Yes" value, your formula would be (also assuming B2 was the active cell - you would see the address in the Name box, directly to the left of the formula bar):

=B$1="Yes"

Then each column from row 2 to 10 would look at the same column in row 1 for a "Yes" value, and apply the format if that condition met TRUE.

Hope that explanation helps.

Regards,
Zack Barresse
0
 
LVL 12

Author Closing Comment

by:tel2
ID: 37712792
Thanks again Zack!

Yes, I would have mentioned it up front, except I hadn't even thought of it until I went to do it, which was after you gave me your lightning-fast 1st answer.  Under 4 mins - rediculous!

And thanks imnorie for your well-laid-out answer.  Sorry - all points go to Zack this time, because he got in first and had all the info I needed.

Keep up the good work, guys.
Tel2
0
 
LVL 14

Expert Comment

by:Zack Barresse
ID: 37712810
Thanks Tel2, take care!

-Zack
0

Featured Post

Gigs: Get Your Project Delivered by an Expert

Select from freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely and get projects done right.

Question has a verified solution.

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

No matter the version of Windows you are using, you may have some problems with Windows Search running too slow or possibly not running at all. Before jumping into how you can solve this issue, just know there are many other viable alternative deskt…
Do you use a spreadsheet like Microsoft's Excel?  Have you ever wanted to link out to a non excel file on your computer or network drive?  This is the way I found to do it!
This Micro Tutorial will demonstrate in Microsoft Excel how to add style and sexy appeal to horizontal bar charts.
Finds all prime numbers in a range requested and places them in a public primes() array. I've demostrated a template size of 30 (2 * 3 * 5) but larger templates can be built such 210  (2 * 3 * 5 * 7) or 2310  (2 * 3 * 5 * 7 * 11). The larger templa…

786 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