Solved

Excel: Format cell based on contents of other cell

Posted on 2012-03-12
8
353 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
[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
  • 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 34

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
PeopleSoft Has Never Been Easier

PeopleSoft Adoption Made Smooth & Simple!

On-The-Job Training Is made Intuitive & Easy With WalkMe's On-Screen Guidance Tool.  Claim Your Free WalkMe Account Now

 
LVL 34

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

On Demand Webinar: Networking for the Cloud Era

Did you know SD-WANs can improve network connectivity? Check out this webinar to learn how an SD-WAN simplified, one-click tool can help you migrate and manage data in the cloud.

Question has a verified solution.

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

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!
How to get Spreadsheet Compare 2016 working with the 64 bit version of Office 2016
This Micro Tutorial will demonstrate how to use a scrolling table in Microsoft Excel using the INDEX function.
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

687 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