# Question for an excel formula

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?
LVL 1
###### Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Commented:
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
Author Commented:
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?
Commented:
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
Commented:
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

Experts Exchange Solution brought to you by

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Author Commented:
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
Commented:
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
Author Commented:
Thank you for the help. I had to remove the \$ and then it worked
###### It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Microsoft Excel

From novice to tech pro — start learning today.