Solved

Question for an excel formula

Posted on 2012-03-25
7
321 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
Live: Real-Time Solutions, Start Here

Receive instant 1:1 support from technology experts, using our real-time conversation and whiteboard interface. Your first 5 minutes are always free.

 
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

Gigs: Get Your Project Delivered by an Expert

Select from freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely and get projects done right.

Question has a verified solution.

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

Convert between Excel file formats (.XLS, .XLSX, .XLSM) with/without macro option David Miller (dlmille) Intro Over this past Fall, I've had the opportunity to see several similar requests and have developed a couple related solutions associate…
This code takes an Excel list of URL’s and adds a header titled “URL List”. It then searches through all URL’s in column “A”, looking for duplicates. When a duplicate is found, it is moved to the top of the list. The duplicate URL’s are then highlig…
The viewer will learn how to use a discrete random variable to simulate the return on an investment over a period of years, create a Monte Carlo simulation using the discrete random variable, and create a graph to represent the possible returns over…
This Micro Tutorial will demonstrate in Google Sheets how to use the HYPERLINK function to create live links inside your spreadsheet.

785 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