Solved

Excel: Format cell based on contents of other cell

Posted on 2012-03-12
8
344 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
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.

 
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

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

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.

Question has a verified solution.

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

Since upgrading to Office 2013 or higher installing the Smart Indenter addin will fail. This article will explain how to install it so it will work regardless of the Office version installed.
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 how to use a scrolling table in Microsoft Excel using the INDEX function.
This Micro Tutorial will demonstrate how to create pivot charts out of a data set. I also added a drop-down menu which allows to choose from different categories in the data set and the chart will automatically update.

831 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