Specific Cell with Conditional formatting in a table - Sorting Problem.

pikalex

New Member
Joined
May 20, 2020
Messages
3
Office Version
  1. 2016
Platform
  1. Windows
Hi Mr. Excel community.

I am facing a problem with a table with contains only few specific cells with a conditional formating based on its own value. The problem is that when I sort the table in any way, the conditional formatting in the specific cell does not follow the row it's in. It stays at the same absolute cell when the conditional formatting was first created.

I created an example of the Excel file at this link with more information in it : SortingTableConditionalProblem.xlsx.

SortingTableConditionalProblem.xlsx
BCD
4ExpenseYearlyMonthly
5B (User input on Monthly)-12-1
6A (User input Yearly)0
7C (User input on Yearly)00
8D (User input on Monthly)121
Sheet1
Cell Formulas
RangeFormula
C5,C8C5=12*[@Monthly]
D6:D7D6=[@Yearly]/12
Cells with Conditional Formatting
CellConditionCell FormatStop If True
C6Cellcontains a blank value textNO
C6Cell Value>=0textNO
C6Cell Value<0textNO
D5Cellcontains a blank value textNO
D5Cell Value>=0textNO
D5Cell Value<0textNO
D8Cellcontains a blank value textNO
D8Cell Value>=0textNO
D8Cell Value<0textNO
C7Cellcontains a blank value textNO
C7Cell Value>=0textNO
C7Cell Value<0textNO


Row A and C have a formula in Monthly column based on the yearly cell calue entered by the user.
Row B and D have a formula in Yearly column based on the Monthly cell calue entered by the user.

Each cell to be entered by the user has to be Highlited with the following rules:
1) Dark Green if the field is empty.
2) Light Green if the field is greater or equal to 0.
3) Red if the field is lower than 0.

After sorting A -> Z, the output is bad. The cell conditional formatting stayed at the same place so color code does match the cell that the user has to input and the color code applies to the cell with a formula in it...

SortingTableConditionalProblem.xlsx
BCD
15ExpenseYearlyMonthly
16A (User input Yearly)0
17B (User input on Monthly)-12-1
18C (User input on Yearly)00
19D (User input on Monthly)121
Sheet1
Cell Formulas
RangeFormula
D16,D18D16=[@Yearly]/12
C17,C19C17=12*[@Monthly]
Cells with Conditional Formatting
CellConditionCell FormatStop If True
C17Cellcontains a blank value textNO
C17Cell Value>=0textNO
C17Cell Value<0textNO
D16Cellcontains a blank value textNO
D16Cell Value>=0textNO
D16Cell Value<0textNO
D19Cellcontains a blank value textNO
D19Cell Value>=0textNO
D19Cell Value<0textNO
C18Cellcontains a blank value textNO
C18Cell Value>=0textNO
C18Cell Value<0textNO


When we look at the Conditional Formatting Rules Manager, we can that the rules "Applies to" an absolute cell. If I try to remove the $ signs to make it relative, when I click on Apply, the $ signs automatically reappear…

I need new ideas to solve this problem. Anyone?

Thank you for your time.
 

Excel Facts

When they said...
When they said you are going to "Excel at life", they meant you "will be doing Excel your whole life".
Hi Pikalex,

Try removing the duplicate formats and have the "Applies to" change to the range of all cells you want to conditionally format. As it's a table it should then automatically extend the conditional format to any added rows.

1589974365008.png
 
Upvote 0
Hi Toadstool,

It would work fine if I wanted to apply the rules for every cells of these 2 columns. The thing is I just want to color the cells where the user has to enter a value, not the one with formulas.
 
Upvote 0
I used Toadstool's idea with more specific formulas to get what I needed. The idea is to look if the cell contains a formula and looking if the cell is either blank, negative or <=0 in this specific order.

SortingTableConditionalProblem.xlsx
BCD
35ExpenseYearlyMonthly
36B (User input on Monthly)-12-1
37A (User input Yearly)0
38C (User input on Yearly)00
39D (User input on Monthly)121
Sheet1
Cell Formulas
RangeFormula
C36,C39C36=12*[@Monthly]
D37:D38D37=[@Yearly]/12
Cells with Conditional Formatting
CellConditionCell FormatStop If True
C36:D39Expression=AND(ISFORMULA(C36)=FALSE,C36<0)textNO
C36:D39Expression=AND(ISFORMULA(C36)=FALSE,ISBLANK(C36))textNO
C36:D39Expression=AND(ISFORMULA(C36)=FALSE,C36>=0)textNO


Now the problem is that is the user enters a formula the user cell will dissappear. This may be alright in certain cases or not.

Altough it is not perfect it is the closest I can get and it will be good enough for now. I think it can be improved to resolve this.
 
Upvote 0

Forum statistics

Threads
1,215,054
Messages
6,122,897
Members
449,097
Latest member
dbomb1414

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