relative vs absolute in conditional formatting

lezawang

Well-known Member
Joined
Mar 27, 2016
Messages
1,805
Office Version
  1. 2016
Platform
  1. Windows
Hi
I am try to understand conditional formatting. I could not understand why the author used this formula

=$B2>75

why $B2

She explained here (below) but I did not understand. I would appreciate if you can explained easier for me. Thanks a lot.

+++++++++++++++++++++++++++++++++++++
we'll refer to cell B2, because it's in the active row.
=$B2>75
We use an absolute reference to column B ($B), to ensure that the conditional formatting in all columns refers to the value in column B.
If we used a relative reference (B), the formula will be adjusted in each column, and won't work properly. Each cell would refer to the cell to its right, instead of refering to the cell in column B.
 
Maybe some pictures ;)

This first table is how CF applies the formula: =$B2>75

ABCDE
1
2cf: =$b2>7576cf: =$b2>75cf: =$b2>75cf: =$b2>75
3cf: =$b3>7565cf: =$b3>75cf: =$b3>75cf: =$b3>75
4cf: =$b4>7553cf: =$b4>75cf: =$b4>75cf: =$b4>75
5cf: =$b5>75100cf: =$b5>75cf: =$b5>75cf: =$b5>75

This second table shows which cells from the above formula would be highlighted. (Assume column B also has the cf applied to it)

ABCDE
1
2true76truetruetrue
3false65falsefalsefalse
4false53falsefalsefalse
5true100truetruetrue

This third table shows how CF applies the formula: =B2>75

ABCDE
1
2cf: =b2>7576cf: =d2>75cf: =e2>75cf: =f2>75
3cf: =b3>7565cf: =d3>75cf: =e3>75cf: =f3>75
4cf: =b4>7553cf: =d4>75cf: =e4>75cf: =f4>75
5cf: =b5>75100cf: =d5>75cf: =e5>75cf: =f5>75

Does this help at all?
 
Upvote 0

Excel Facts

Ambidextrous Undo
Undo last command with Ctrl+Z or Alt+Backspace. If you use the Undo icon in the QAT, open the drop-down arrow to undo up to 100 steps.
Thanks a lot again. I start getting the idea of selecting .. now row 2 (because B2 is there) is going to be highlighted. that is fine but at same argument, i can say why not the whole column B got highlighted? it was selected too? Thank you.
 
Upvote 0
Think of it as you entering the formula and copying it in the spreadsheet(this is what conditional formatting is doing behind the scene)

NAME Address DATA
Bob 123 fs data beth FALSE FALSE FALSE
Beth 5t25 data1 TRUE TRUE TRUE
Rick sg stuff FALSE FALSE FALSE
Coral fs things FALSE FALSE FALSE

If you do not get the right true and false when you do this you will not get the right conditional formatting.
 
Upvote 0
Thanks a lot again. I start getting the idea of selecting .. now row 2 (because B2 is there) is going to be highlighted. that is fine but at same argument, i can say why not the whole column B got highlighted? it was selected too? Thank you.

If you put the formula as =$B$2, then the whole column would highlight if B2 was greater than 75. With only $B2, then the cf adjusts the formula just like it adjusts when you copy it down a column. It goes $B2, then $B3, then $B4 etc ... each row compares against its respective cell in column B. ie: Row 75 would check cell B75, not B2.
 
Upvote 0
I start getting the idea of selecting .. now row 2 (because B2 is there) is going to be highlighted. that is fine but at same argument, i can say why not the whole column B got highlighted? it was selected too?
I cannot tell if you are saying you are good now, or are still failing to understand.

If you still do not understand, it seems that you do not understand what the "selected range" is. It is whatever range you highlight with your mouse, or select with your cursor. It could be one single cell, but it doesn't have to be. It can be whole rows, whole columns, or selected multi-cell ranges.

Here is a simple macro that will tell you what range you have selected at that point in time:
Code:
Sub MySelection()
    MsgBox Selection.Address(0, 0) & " has been selected."
End Sub
"B2" represents one single cell, specificially cell B2
"A10:Z50" represents the range from cell A10 to cell Z50
"2:7" represents rows 2 through 7
"D:F" represents columns D through F
etc
 
Upvote 0
Yes got it. I am so grateful to all of you indeed. Many thanks and great respect for your amazing skills and knowledge.
So grateful once again. Thank you all.
 
Upvote 0

Forum statistics

Threads
1,216,000
Messages
6,128,204
Members
449,435
Latest member
Jahmia0616

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top