Conditional Format multiple cells

User avatar
Sundog
5StarLounger
Posts: 704
Joined: 28 Jan 2010, 22:47
Location: Alien Country (Roswell NM)

Conditional Format multiple cells

Post by Sundog »

Edit: corrected cell references.

My challenge is to format a list of cells based on values in an adjacent list. Example: Format B2 green if B2>A2, format B2 red if B2<A2. Do this for B2:B11. (No format if B2=A2 is fine.)

breakout.PNG
Edit: If I try to copy the format in B2 to B3:B11, doesn't work since B2 conditional format looks at value of =A2, not the formula =A2. So B3 looks for the value displayed in A2, not what's in A3.
You do not have the required permissions to view the files attached to this post.
Last edited by Sundog on 15 Mar 2022, 22:13, edited 1 time in total.
Sundog

User avatar
HansV
Administrator
Posts: 78594
Joined: 16 Jan 2010, 00:14
Status: Microsoft MVP
Location: Wageningen, The Netherlands

Re: Conditional Format multiple cells

Post by HansV »

Select B2:B11.
B2 should be the active cell in the selection.

On the Home tab of the ribbon, select Conditional Formatting > New Rule...
Select 'Format only cells that contain'.
Leave the first dropdown set to 'Cell Value'.
Select 'greater than' from the second dropdown.
Enter =B1 in the box next to it.
Click Format...
Activate the Fill tab.
Select green.
Click OK, then click OK again.

Repeat these steps, but this time with 'less than' from the second dropdown, and red as fill color.
Best wishes,
Hans

User avatar
Sundog
5StarLounger
Posts: 704
Joined: 28 Jan 2010, 22:47
Location: Alien Country (Roswell NM)

Re: Conditional Format multiple cells

Post by Sundog »

See my edit, sorry for the confusion and incorrect initial entries.
Sundog

User avatar
HansV
Administrator
Posts: 78594
Joined: 16 Jan 2010, 00:14
Status: Microsoft MVP
Location: Wageningen, The Netherlands

Re: Conditional Format multiple cells

Post by HansV »

Select B2:B11.
B2 should be the active cell in the selection.

On the Home tab of the ribbon, select Conditional Formatting > New Rule...
Select 'Format only cells that contain'.
Leave the first dropdown set to 'Cell Value'.
Select 'greater than' from the second dropdown.
Enter =A2 in the box next to it. Make sure that it's NOT =$A$2
Click Format...
Activate the Fill tab.
Select green.
Click OK, then click OK again.

Repeat these steps, but this time with 'less than' from the second dropdown, and red as fill color.
Best wishes,
Hans

User avatar
Sundog
5StarLounger
Posts: 704
Joined: 28 Jan 2010, 22:47
Location: Alien Country (Roswell NM)

Re: Conditional Format multiple cells

Post by Sundog »

Here is what I see after I try it on C19:D24. Starting from D19:D24 highlighted, D19 active cell.

[attachment=0]b2.PNG[/attachment}

Looks right, but if I change d24 to >c24 by entering a new number larger than c24, color stays red.
You do not have the required permissions to view the files attached to this post.
Sundog

User avatar
Sundog
5StarLounger
Posts: 704
Joined: 28 Jan 2010, 22:47
Location: Alien Country (Roswell NM)

Re: Conditional Format multiple cells

Post by Sundog »

My problem. Entered c19, s/b =c19.

Fixed. Thanks, Hans.

This will replace twenty Conditional Formatting rules a day!
Last edited by Sundog on 15 Mar 2022, 22:45, edited 1 time in total.
Sundog

User avatar
HansV
Administrator
Posts: 78594
Joined: 16 Jan 2010, 00:14
Status: Microsoft MVP
Location: Wageningen, The Netherlands

Re: Conditional Format multiple cells

Post by HansV »

If you look closely, c19 is enclosed in quotes. This makes me suspect that you entered c19 in the box instead of =C19
It should look like this:

S1216.png
S1217.png
You do not have the required permissions to view the files attached to this post.
Best wishes,
Hans

User avatar
Sundog
5StarLounger
Posts: 704
Joined: 28 Jan 2010, 22:47
Location: Alien Country (Roswell NM)

Re: Conditional Format multiple cells

Post by Sundog »

Correctamudo. :thankyou:
Sundog

User avatar
ChrisGreaves
PlutoniumLounger
Posts: 15645
Joined: 24 Jan 2010, 23:23
Location: brings.slot.perky

Re: Conditional Format multiple cells

Post by ChrisGreaves »

Sundog wrote:
15 Mar 2022, 21:59
My challenge is to format a list of cells based on values in an adjacent list.
Hi Sundog. If you would like an example, download the file http://www.chrisgreaves.com/Downloads/Stats.xls from my web site.
I use the date field (column A) to alert myself when I am falling behind my self-imposed schedule.

I think that I am falling behind schedule when I discover a track that has NOT been recorded by close to its scheduled date.
If you load the workbook over a period of three or four consecutive days without changing the data, the number of red-font cells should increase.
Cheers
Chris
He who plants a seed, plants life.

CraigS26
2StarLounger
Posts: 156
Joined: 02 Nov 2016, 12:56

Re: Conditional Format multiple cells

Post by CraigS26 »

Student-Hm Office 2016
Any idea why Mine doesn't respect B > A2 = Green?

Image
Image
Win 10 Pro 22H2 | ESET EIS Prem | Mbam Prem | Diskeeper Pro '15 | Macrium Pd v8

User avatar
StuartR
Administrator
Posts: 12622
Joined: 16 Jan 2010, 15:49
Location: London, Europe

Re: Conditional Format multiple cells

Post by StuartR »

CraigS26 wrote:
16 Mar 2022, 13:19
Student-Hm Office 2016
Any idea why Mine doesn't respect B > A2 = Green?
Because you have specified ="A2" instead of =A2, so it is comparing B to the literal string "A2" instead of to the value in the cell A2
StuartR


CraigS26
2StarLounger
Posts: 156
Joined: 02 Nov 2016, 12:56

Re: Conditional Format multiple cells

Post by CraigS26 »

Thanks, Stuart. I noticed the quotes and failed to mention them.
So default entry of A2 (App puts = & " ") is an auto-error in this case. Whodathunkit.
All is well.
Win 10 Pro 22H2 | ESET EIS Prem | Mbam Prem | Diskeeper Pro '15 | Macrium Pd v8

User avatar
HansV
Administrator
Posts: 78594
Joined: 16 Jan 2010, 00:14
Status: Microsoft MVP
Location: Wageningen, The Netherlands

Re: Conditional Format multiple cells

Post by HansV »

You have to enter it in the form =A2. If you just enter A2, Excel converts it to a quoted string as you have found.
Best wishes,
Hans

CraigS26
2StarLounger
Posts: 156
Joined: 02 Nov 2016, 12:56

Re: Conditional Format multiple cells

Post by CraigS26 »

Thanks, Hans. I'll make an appt with an ADD doctor as your point about = is all over this thread....
Win 10 Pro 22H2 | ESET EIS Prem | Mbam Prem | Diskeeper Pro '15 | Macrium Pd v8