Forum Discussion
conditional formatting doesn't work with complex "IF" statement
It's because the formula evaluates to an error in Conditional Formatting.
So it'd be useful to know what you want to accomplish.
- captainFlowOct 31, 2022Copper Contributor
HansVogelaar , Patrick2788 Thanks for help, special thank to JMB17 . This function really works for me, but one more thing you should think about is my formula became longer then 255 symbols, so I added function for getting current cell value to name manager via LAMBA function.
- captainFlowOct 28, 2022Copper Contributor
Patrick2788
Hi
Thanks for your reply, initially my function isn't supposed for using in big books, but thanks for yours warnings. - Patrick2788Oct 25, 2022Silver ContributorThe trade off with this is the reliance on volatile functions. Excel will re-evaluate any cells (and dependents) each time it re-calculates. This would be every cell containing the conditional formatting rule and any cells referred to in your formula. Additionally, conditional formatting formulas are single threaded. You can see why this might be a performance concern with a large workbook.
https://learn.microsoft.com/en-us/office/client-developer/excel/excel-recalculation - HansVogelaarOct 25, 2022MVP
I fear you're chasing rainbows...
- captainFlowOct 25, 2022Copper Contributor
HansVogelaar
One more thing that could help me is function like ROW or COLUMN, which returns value each cell during calculation. As I said before I found CELL function, but it doesn't work correctly for me. - HansVogelaarOct 22, 2022MVP
I'm afraid I don't know how to do that.
- captainFlowOct 22, 2022Copper ContributorSure, I know about relatives field functionality, but I want to make completly independet formula to make it usage much more simple.
- HansVogelaarOct 21, 2022MVP
The reference to G1 in my example is relative. Excel will automatically adjust it for the other cells in the selected range. So when evaluating the conditional formatting rule for cell G2, it will use G2 in the formula instead of G2, and when evaluating the rule for cell H1, it will use H1 instead of G1, etc.
So you only have to refer to the top left cell of the selected range, and Excel will take care of the rest for you.
- captainFlowOct 20, 2022Copper ContributorThanks
But do we have ability to solve it without references such as G1 ? Do we have any function like ROW() or COLUMN() to get value for each cell during calculations? - HansVogelaarOct 20, 2022MVP
Let's say you want to apply the conditional formatting to G1:K100.
Select this range. G1 should be the active cell in the selection.
Use the following formula in the conditional formatting rule:
=OR(G1="";IF(ROW(G1)=1;G1>=1,1*$D$2;OFFSET(G1;-1;0)>=1,1*$D$2))
=ИЛИ(G1="";ЕСЛИ(СТРОКА(G1)=1;G1>=1,1*$D$2;СМЕЩ(G1;-1;0)>=1,1*$D$2))
You may have to adjust the multiplication factor 1,1
- captainFlowOct 20, 2022Copper Contributor
HansVogelaar
It should return 0 if cell is empty.
If it is cell from the 1st row it should return 1 if cell's value is X percent more than the value in $D2 (for example) cell and 0 otherwise.
If it is cell from non the 1st row it should return 1 if value from the current cell is X percents more that value from the cell from the previous row but the same column.
Thanks for your help. I appreciate it. - HansVogelaarOct 20, 2022MVP
Yes: > What I want my formula does?
- captainFlowOct 20, 2022Copper Contributor
HansVogelaar
It may be incorrect after I translated in English, because I wrote it in Russian and I use Russian for all formulas I write because it it local language for my document. Notice, please, that this formula works fine when I put it as fomula into the cell. I face with troubles during putting it in the formula for Conditional Formatting.
Formula doesn't have accurate bounds, so I can't say the range. I want it will work for many colums. But this formula contain one absolute cell adress.
What do you means with conditions? What I want my formula does? - HansVogelaarOct 20, 2022MVP
Your formula is syntactically incorrect, and I suspect it is far more complicated than necessary.
What is the range you want to format?
And what are the conditions?
- captainFlowOct 20, 2022Copper Contributor
HansVogelaar I spent few minutes for searchin this error meaning but found nothing usefull. I use INDIRECT(ADRESS(ROW();COLUMN())) - only for getting current value during Conditional Formatting evaluations, so it seems complex but I don't know how to make it in a different way.
I also tried to use CELL("value") function, but it behaves strange, seems like it doesn't get each cell's value for each evaluation, but gets ONE value for all evaluations for Conditional Formatting within current range. - HansVogelaarOct 20, 2022MVP
I don't know why it causes an error, but it does. In the Immediate window of the Visual Basic Editor:
Debug.Print Evaluate("=INDIRECT(ADRESS(ROW(),COLUMN()))")
Error 2029