Looks like no one’s replied in a while. To start the conversation again, simply ask a new question.

Can conditional formatting detect formulas?

I have a spreadsheet for home accounts/debts etc, and I like to put forward calculations in columns so I can get an idea of how long it will take to pay off debts. These forward calculations are formulas based on APRs etc, and I manually format them in grey italics. When a bill comes in with the actual amount on it, that formula gets replaced with the bill amount, and I switch the format to black plain text so I can see it's an actual value.


Is there any way, using conditional formatting or otherwise, I can automate this so that when I type in a real value it can detect it's not a formula and reformat the cell?


Thanks!

MacBook Pro, Mac OS X (10.6.8), 13" Core 2 Duo 2.4 GHz

Posted on Nov 12, 2011 4:37 AM

Reply
Question marked as Best reply

Posted on Nov 12, 2011 11:36 AM

No.


Conditional format rules depend on comparing the value contained in the cell, and pay no attention to how that value got there.


That said, it might be possible to examine the value and determine whether it was entered directly or formula generated. If the value in the cell is NOT equal to the value in the cell rounded to two decimal places, then chances are the value was generated by a formula. Not perfect, as it will not detect generated values that are exact to zero, one or two decimal places (eg. 12.00000, 12.10000, 12,12000, etc), and won't find any values where the formula itself actually rounds (as opposed to 'displays') its result to two (or fewer) decimal places.


Here's an example:

User uploaded file

As indicated in column A. the values in B2 and B3 are entered numbers, those in B4 and B5 are calculated. Column B is formatted to DISPLAY these numbers as Currency, with the usual two decimal places.


Column C uses the formula =B to transfer the actual values in column B. Formatting is set to automatic.


Column D uses the formula =ROUND(B,2) which rounds the values in column B to two decimal places. Formatting is set to automatic, so what is shown is the actual value.


The conditional formatting rule, shown for cell B5, compares the actual value in column B with its rounded counterpart in column D. If they are the same, the assumption (wrong, in this case) is that the value was entered, and the rule applies bold style to the text and a light grey fill to the cell. If they are different, no change is made.


Note that there's some tedium involved in setting this up, as the rule for each cell uses a different comparison cell, and these must be set (or reset) individually.


Regards,

Barry

20 replies
Question marked as Best reply

Nov 12, 2011 11:36 AM in response to Jowie

No.


Conditional format rules depend on comparing the value contained in the cell, and pay no attention to how that value got there.


That said, it might be possible to examine the value and determine whether it was entered directly or formula generated. If the value in the cell is NOT equal to the value in the cell rounded to two decimal places, then chances are the value was generated by a formula. Not perfect, as it will not detect generated values that are exact to zero, one or two decimal places (eg. 12.00000, 12.10000, 12,12000, etc), and won't find any values where the formula itself actually rounds (as opposed to 'displays') its result to two (or fewer) decimal places.


Here's an example:

User uploaded file

As indicated in column A. the values in B2 and B3 are entered numbers, those in B4 and B5 are calculated. Column B is formatted to DISPLAY these numbers as Currency, with the usual two decimal places.


Column C uses the formula =B to transfer the actual values in column B. Formatting is set to automatic.


Column D uses the formula =ROUND(B,2) which rounds the values in column B to two decimal places. Formatting is set to automatic, so what is shown is the actual value.


The conditional formatting rule, shown for cell B5, compares the actual value in column B with its rounded counterpart in column D. If they are the same, the assumption (wrong, in this case) is that the value was entered, and the rule applies bold style to the text and a light grey fill to the cell. If they are different, no change is made.


Note that there's some tedium involved in setting this up, as the rule for each cell uses a different comparison cell, and these must be set (or reset) individually.


Regards,

Barry

Nov 12, 2011 3:31 PM in response to Jowie

This isn't exactly what you want, but it might do.


Set the cell format to "Number" then set the format for negative numbers to red, no minus.


Set a conditional format to non-italic for greater than or equal to 0, and to italic for less than 0.


Multiply all your formulas by -1.


This way, if the value is from a formula it will appear red and italic (not grey, sorry, I can't figure that one out) because it will be negative, and if it is entered directly it will appear black and non-italic because it is positive.


This assumes that none of the values (calculated or direct entry) would ever be negative, but that doesn't seem to be an issue in this situation since it is length of time to pay off debts.

Nov 12, 2011 3:56 PM in response to John De Banzie

"This assumes that none of the values (calculated or direct entry) would ever be negative, but that doesn't seem to be an issue in this situation since it is length of time to pay off debts."


Won't work that easily, John. The values calculated are future payments; they're replaced with amounts that are actual payments. The amount in the cell is used in further calculations that determine the number of payments needed to complete repayment of the debt.


To make it work, assuming the payments are all positive values, the OP would have to multiply the formulas by -1, as you suggest, then track down any formulas that used the value in the cell and revise those formulas to use the absolute value (eg. ABS(A1) ).


Regards,

Barry

Nov 13, 2011 5:46 AM in response to Jowie

Lots of interesting solutions here, many thanks for the thought and effort! It's a shame that a perfect solution can't be found... There are quite a few columns of data so I can imagine it would get really complicated if I started adding hidden columns with extra data just for formatting purposes, and knowing me I could break something in the process!


Unless there's something I can do with macros?

Nov 13, 2011 6:31 AM in response to Jowie

Can't you create a new column which contains the ACTUAL amount you paid which will override the projecgted payment?


User uploaded file

In this case so long as the cells in the "Amount Paid" column are blank the Balance is reduced by the projected amount. When you enter an Actual Amount the balance is reduced by the actual amount.


E3=C2-IF(ISBLANK(E3), D3, E3)


fill down

Nov 13, 2011 6:39 AM in response to Jowie

Jowie,


Your original question about formatting and your problem statement about forecasting are two different issues, in my mind. And, of course, perfection is rarely achieved. I can imagine some effective forecasting enhancements to your document that don't involve detecting whether a cell has directly entered data or not, but chasing perfection isn't usually a satisfying effort.


Adressing only your format question, here's my approach. In your calculation, display a non-printing character that can be detected by Conditional Format. One example is to add a leading space, usually not noticed by the reader, and then Conditional Format based on the presence of "Begins With" a space character.


Jerry

Nov 13, 2011 11:50 AM in response to Jerrold Green1

No the forecasting is sorted... No problems at all there. I've got the forward calculations very accurate, and they are based on APR and payments made. The only problem I have is reformatting... It's only a niggle really... When I get the actual value from a bill, I enter it over the top of the calculation/formula already in the cell, then change it to black and non-italic... It's just a step I was hoping to avoid.


The problem with the "begins with a space" solution is that it won't work because my cells are formatted for currency. If I add a space, the next time I edit it the space is gone again.

Nov 13, 2011 3:34 PM in response to Barry

It is a nice solution and if my spreadsheet was smaller I could see it possibly working. But unfortunately, it overcomplicates things for the size of spreadsheet I have. I already have as many columns as I can fit onto the screen to see it all at a glance, and by adding an extra column next to each one that already exists will mean I can't see all the correct values next to each other. Not only that, it defeats the object of using conditional formatting to make the numbers easier to see, because it introduces another column of numbers.


It also means that the graphs I have set up will no longer work, because extra columns have been inserted which don't add up in the same way. I also have a lot of SUM() calculations for rows, which also wouldn't work with two columns per debt.

Nov 13, 2011 5:03 PM in response to Jowie

Jowie wrote:


No the forecasting is sorted... No problems at all there. I've got the forward calculations very accurate, and they are based on APR and payments made. The only problem I have is reformatting... It's only a niggle really... When I get the actual value from a bill, I enter it over the top of the calculation/formula already in the cell, then change it to black and non-italic... It's just a step I was hoping to avoid.


The problem with the "begins with a space" solution is that it won't work because my cells are formatted for currency. If I add a space, the next time I edit it the space is gone again.

I think you missed my point. The leading space is in the formula, not the override.


Here's an example:


User uploaded file


Jerry

Nov 14, 2011 9:06 AM in response to Jerrold Green1

That seemed uncalled for. Why am I resistant to suggestion? You suggested something, I tried it out and it didn't work. I would never reply to something saying "it doesn't work" when I haven't yet tried it. If I sound negative, it's only because I haven't found a solution that works for me yet... 🙂


Okay so here's the proof that I've tried and it didn't work:


User uploaded file User uploaded fileUser uploaded file

I don't know why it works for you, but unfortunately it doesn't work for me. 😟


Thanks to everyone for your help, by the way. I am not ungrateful!

Can conditional formatting detect formulas?

Welcome to Apple Support Community
A forum where Apple customers help each other with their products. Get started with your Apple ID.