Solved

Question for an excel formula

Posted on 2012-03-25
7
325 Views
Last Modified: 2012-03-26
I want to compare 2 Excel cells as per the following

if A1 < A2 then highlight A2 cell

I'm using Excel 2010. How can I do this?
0
Comment
Question by:Gerhardpet
[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
  • 3
  • 3
7 Comments
 
LVL 50

Expert Comment

by:barry houdini
ID: 37763272
Try Conditional formatting

Select A2 then on "Home" tab - Conditional formatting > New rule > Use a formula to determine which cells to format > type this formula in the box

=A1<A2

Select required formatting > OK

You can also apply that to a larger range if required

regards, barry
0
 
LVL 1

Author Comment

by:Gerhardpet
ID: 37763307
Ok I did what you told which works but I can't figure out how to apply it to a large range of cells. When I use the format Painter it does the following

My rule is =A1<B1 then highlight in red

Now when I use the format painter my next row is =A1<B2 but I want it to be A2<B2

Does that make sense?
0
 
LVL 5

Assisted Solution

by:chinawal
chinawal earned 250 total points
ID: 37763343
Gerhardpet,
See attached excel.
I had a rule =A1<B1 then highlight in red
I was able to use the format painter on next row correctly i.e. A2<B2

So, not sure, what exact issue you are having.
book1.xlsx
0
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 50

Accepted Solution

by:
barry houdini earned 250 total points
ID: 37763351
Make sure you don't use any $ signs in the formula otherwise that will "fix" the cell references.

If you want to apply to a larger range you can simply change the "Applies to" range in the conditional formatting rule

regards, barry
0
 
LVL 1

Author Comment

by:Gerhardpet
ID: 37763579
So far it does not work. I think what I need is for each cell to have a new rule.

chinawal, in your attachment you do not have a rule for each cell.

I found that I can create a new rule in one cell at the time using the format painter but that is still a lot of work considering that I have about 100 cells
0
 
LVL 50

Expert Comment

by:barry houdini
ID: 37763627
No, you don't need a new rule for each cell.

Chinawal's suggestion does what you want I believe. Although the rule says

=A2<B2

that will adjust for each cell in the "applies to" range. Look at the results: 4 in B3 is highlighted (because it > 3 in A3) while the 4 in B7 is not highlighted (because it isn't > 4 in A7).

In Excel 2003 the conditional formatting formula explicitly changed for each cell - after 2007 that changed, you only see a single rule.......but the rule applies "as is" to the first cell in the "applies to" range (B2), and then adjusts (implicitly) for all cells in the range as if copied down as a worksheet formula [=A2<B2 in row 2 will adjust to =A3<B3, =A4<B4 etc. )

So you have 3 options

1 - choose just B2 and apply that formula, then use format painter to copy to other cells,

2 - choose just B2 and apply that formula, then change "applies to" range to whatever range is required,

3. select whole range, e.g. B2:B100 and apply that same formula

All of those methods will work

regards, barry
0
 
LVL 1

Author Closing Comment

by:Gerhardpet
ID: 37765361
Thank you for the help. I had to remove the $ and then it worked
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Suggested Solutions

This article will guide you to convert a grid from a picture into Excel format using Microsoft OneNote and no other 3rd party application.
This article descibes how to create a connection between Excel and SAP and how to move data from Excel to SAP or the other way around.
This Micro Tutorial demonstrates how to create Excel charts: column, area, line, bar, and scatter charts. Formatting tips are provided as well.
Excel styles will make formatting consistent and let you apply and change formatting faster. In this tutorial, you'll learn how to use Excel's built-in styles, how to modify styles, and how to create your own. You'll also learn how to use your custo…

738 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