0
votes

I am trying to figure an Excel formula and Google is not helping. I almost have what I am trying to do, but need a 'dummy' column where I do the math in the column cells.

What this means:

1) What I have working:

Cell A1, with math formula (I wish to delete this 'dummy' cell and incorporate this into the formula in Cell B1, see further explanation below)

=SUM((6.75*1)+(5.73*2)+3)

Cell B1, with value from Cell A1 but limited to an integer less than or equal to 80

=IF(SUM(A1)>80, 80, SUM(A1))

Cell C1, with a value looking at Cell B1 and entering in this cell either 0 or any integer greater than 80

=IF(SUM(A1)>80,SUM(A1)-80,"0")

Note: This works perfectly, I change any values in the Cell A1 formula and it correctly reflects in Cells B1 & C1.

2) The missing piece:

I would like to combine the two formulas above in cells A1 & B1 into one cell, and still have the same results described above for each of the cells.

To articulate this another way is:

  • have a cell with a math formula,
  • calculate the results of that formula, and then,
  • enter back in the same cell that formulas results,
  • with the condition of 'less than or equal to 80'
  • while a formula in an adjacent cell is dependent on the calculated, but un-printed, value of the first cell.

As an example:

Using only Cells A1 and B1 in a spreadsheet, and combining the above working formulas (which do not work for me in Excel), it would look like this:

Cell A1:

=IF(SUM((6.75*10)+(5.73*7)+8.5)>80, 80, SUM(B21))

Note: Cell A1 formula from above, =SUM((6.75*1)+(5.73*2)+3), combined with Cell B1 formula from above, =IF(SUM(A1)>80, 80, SUM(A1)) (with the Cell A1 formula replacing both 'A1' values in the Cell B1 formula).

Cell B1:

=IF(SUM(A1)>80,SUM(A1)-80,"0")

Note: Identical to the Cell C1 formula above.

Is it possible to do this, calculate the results of a cell's formula, while a formula in an adjacent cell is dependent on the calculated, but un-printed, value of that first cell?

I realize writing this out, it's more complicated than I originally anticipated, which explains why Google wasn't getting me anywhere. Thanks for any hints. Phil

1

1 Answers

1
votes

Strictly speaking, this is not possible. A cell has only 1 value and that is the result of all calculations. The IF statement is not hiding the value of the cell. It is changing the value.

A formula to another cell can only use the final value of the cell. It can't extract part of the formula in the other cell. There's no way for Excel to know which part to extract, even if there's only a single calculation in an IF statement.

That said, there is a different workaround possible in your case... and that is to change how your value is displayed through custom formatting. Formulas change the value of cells, whereas formatting changes how those values are displayed.

  1. Place your formula in cell A1: =6.75*10+5.73*7+3
  2. Right click on cell A1 and select Format Cells...
  3. Make sure you're on the Number Tab
  4. In the Category column, select Custom
  5. Enter this formula in the Type box: [>80]"80";[<=80]General
  6. Enter this formula in B1:=IF(A1>80,A1-80,0)
  7. Check that the number format of B1 is still "General" or "Number"

enter image description here

The result is A1 has calculated and stored the actual value, but displays the text string "80" if it's value is above 80. You can then use the actual value from A1 in other formulas.

NOTE: This type of custom formatting is extremely poor practice as it can become very confusing and very error prone. The value of the cell is different to what it is showing and if other users are unaware, creating new formulas referring to the affected cell can unwittingly produce incorrect and/or unexpected results.

In particular, Excel tries to be helpful and can automatically copy the formatting from one cell to another if it is next to the original cell or if it refers to only the original cell in a basic formula. Copying and pasting also copies the formatting by default. Unintentionally copying the formatting to other cells will also alter how they appear.

Also note that you don't need to put SUM() around a formula that already had the addition operators included; and Excel uses order of operations so you don't need the brackets to do multiplication before addition.

Lastly, you could also just use =MAX(A1-80,0) in B1.