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

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

Excel: Format cell based on contents of other cell

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
tel2
Asked:
tel2
  • 4
  • 2
  • 2
1 Solution
 
Zack BarresseCEOCommented:
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
 
NorieCommented:
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
 
Zack BarresseCEOCommented:
@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
Get your Conversational Ransomware Defense e‑book

This e-book gives you an insight into the ransomware threat and reviews the fundamentals of top-notch ransomware preparedness and recovery. To help you protect yourself and your organization. The initial infection may be inevitable, so the best protection is to be fully prepared.

 
NorieCommented:
Sorry, my mistake.

Got row and column mixed up.
0
 
tel2Author Commented:
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
 
Zack BarresseCEOCommented:
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
 
tel2Author Commented:
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
 
Zack BarresseCEOCommented:
Thanks Tel2, take care!

-Zack
0

Featured Post

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

  • 4
  • 2
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now