Solved

Excel: Format cell based on contents of other cell

Posted on 2012-03-12
8
335 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
 
LVL 33

Expert Comment

by:Norie
ID: 37712631
Sorry, my mistake.

Got row and column mixed up.
0
Better Security Awareness With Threat Intelligence

See how one of the leading financial services organizations uses Recorded Future as part of a holistic threat intelligence program to promote security awareness and proactively and efficiently identify threats.

 
LVL 11

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 11

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 Trending Threat Insights Every Day

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

Improved? Move/Copy Add-in Replacement - How to avoid the annoying, “A formula or sheet you want to move or copy contains the name XXX, which already exists on the destination worksheet.” David Miller (dlmille)  It was one of those days… I wa…
How to quickly and accurately populate Word documents with Excel data, charts and images (including Automated Bookmark generation) David Miller (dlmille) Synopsis In this article you’ll learn how to use ExcelToWord! to copy data,charts, shapes …
The viewer will learn how to create two correlated normally distributed random variables in Excel, use a normal distribution to simulate the return on different levels of investment in each of the two funds over a period of ten years, and, create a …
This Micro Tutorial demonstrate the bugs in Microsoft Excel for Mac with Pivot Charts.

707 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

Need Help in Real-Time?

Connect with top rated Experts

18 Experts available now in Live!

Get 1:1 Help Now