Solved

Question for an excel formula

Posted on 2012-03-25
7
320 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
  • 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
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 
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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Excel - list cell contents that are not duplicated 4 30
Update As Well As Add 6 37
Excel Copy Macro down foe each row 4 18
Filling Blank Cells 14 19
Drop Down List with Unique/Distinct Values (enhancing the Combo-Box with a few steps and a little code) David miller (dlmille) Intro Have you ever created a data validation list from a database field or spreadsheet column (e.g., Zip Codes or Co…
Some code to ensure data integrity when using macros within Excel. Also included code that helps secure your data within an Excel workbook.
The viewer will learn how to use the =DISCRINV command to create a discrete random variable, use this command to model a set of probabilities and outcomes in a Monte Carlo simulation, and learn how to find the standard deviation of a set of probabil…
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 …

911 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

22 Experts available now in Live!

Get 1:1 Help Now