Keeping a conditional format formula from moving while sorting

randaza1

New Member
Joined
Mar 4, 2008
Messages
48
Office Version
  1. 365
Platform
  1. Windows
Hello
The two images are examples of what I am working with.
Briefly D4 = B4-C4 ..................... The same goes for I4 = G4-H4

The result in d4 shows that if I decided to pay this bill on January 31, 2023 it is too early there for it will stripe out yellow and red. < this is a visual for me to rethink the payment date.

The result in I4 shows that if I decided to pay this bill on January 26, 2023 it is within reasonable time (fyi: as long as the Days before... is less than 21 days it not format)

So with that said, here is the QUESTION :)
I normally need to sort my list (which is way bigger than 7 rows I am showing) so as you can see the row with Joes name is the only one that needs to keep this special formatting.
So when I sort the list how do I keep the format of D4 only in the entire row with Joes name. Thanks
Tony

excel picture.jpg
 

Excel Facts

Add Bullets to Range
Select range. Press Ctrl+1. On Number tab, choose Custom. Type Alt+7 then space then @ sign (using 7 on numeric keypad)
What are you sorting? The only difference i see between the two images is the date change for Joe. Maybe you could provide, with the data given, what the desired output would be.
 
Upvote 0
Far question. The following pics may help.
first you will see the condition I am using in cell D2, again this condition is only needed for Joe. The condition that if the days before are more than 19 days format. (yellow red)

second is the list. You see that the 44 days (D2) is greater than the 19 day conditional format. This is what it should do.

third is the list after I sort it alphabetically, you see Joe moved from A2 down to A5, but the condition did not follow Joe, it is now sitting with Abe. Although Abe is 22 days early per this example, it does not matter.

See Joe will not let me pay a bill before 19 days of the due date
the names here can be changed to anything, like Loan 1, Loan 2, Loan 3, etc...

condition.jpg
before sort.jpg
after sort.jpg
 
Upvote 0
this condition is only needed for Joe.
In that case, try this conditional formatting. Note that the CF is applied to all cells in the range D4:D10

23 02 24.xlsm
ABCD
1
2
3Pay toDue DatePay ONDays
4Joe14/02/20231/01/202344
5Abe16/03/202322/02/202322
6Brian16/03/202322/02/202322
7Paul23/02/20239/02/202314
8Kim28/02/20239/02/202319
9Steve1/03/20239/02/202320
10Chris1/03/20239/02/202320
CF with Sort
Cell Formulas
RangeFormula
D4:D10D4=B4-C4
Cells with Conditional Formatting
CellConditionCell FormatStop If True
D4:D10Expression=AND(A4="Joe",D4>19)textNO


After sorting on name:

23 02 24.xlsm
ABCD
1
2
3Pay toDue DatePay ONDays
4Abe16/03/202322/02/202322
5Brian16/03/202322/02/202322
6Chris1/03/20239/02/202320
7Joe14/02/20231/01/202344
8Kim28/02/20239/02/202319
9Paul23/02/20239/02/202314
10Steve1/03/20239/02/202320
CF with Sort
Cell Formulas
RangeFormula
D4:D10D4=B4-C4
Cells with Conditional Formatting
CellConditionCell FormatStop If True
D4:D10Expression=AND(A4="Joe",D4>19)textNO
 
Upvote 0
Solution
Peter_SSs - Thank very much. It works. Sorry it took so long to get back with you. Weather and internet here in Michigan has been trying lately. :)
 
Last edited by a moderator:
Upvote 0

Forum statistics

Threads
1,223,164
Messages
6,170,444
Members
452,326
Latest member
johnshaji

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