Adding a portion of a formula with an operator from another cell

IamBatman

New Member
Joined
Jan 20, 2022
Messages
13
Office Version
  1. 365
  2. 2013
Platform
  1. Windows
I'm creating a spreadsheet that shows what numbers are if we do an increase. We might do that increase by a specific amount or by a percentage. This means my formula might be 16+.25 or 16*1.01

I would like to be able to have that section of the formula that is doing the increasing (+.25 or *1.01) be able to be input from another cell. Is there a way to do that and include the operator (+ or *)? Or would I need to set up two cells and alter my formula?

For context, this is a simplification. The 16 is will actually be a cell reference, and this formula will be in 30 non-continuous cells.
 

Excel Facts

Last used cell?
Press Ctrl+End to move to what Excel thinks is the last used cell.
Try this
Book5
ABCD
1Operand 1OperatorOperand 2Result
26+410
3*24
4^1296
Sheet1
Cell Formulas
RangeFormula
D2:D4D2=EVAL($A$2,B2,$C$2)


You will need to create a VBA function like the following
the values would be in separate cells (see function call above)
VBA Code:
Public Function Eval(operand1, operator, operand2) As Variant
  Eval = Evaluate(Join(Array(operand1, operator, operand2), " "))
End Function

Will a function like this do what you need?
 
Upvote 0
Could you use something like this. H2 contains Data validation which has a choice between "Amount" and "Percentage"

23 08 30.xlsm
ABCDEFGHI
1OriginalNewOriginalNewIncrease TypeIncrease
21616.2518.2618.51Amount0.25
3
4203203.25
5100100.25
Increase
Cell Formulas
RangeFormula
C2,F5,C4,F2C2=(B2+IF($H$2="Amount",$I$2,0))*IF($H$2="Amount",1,$I$2)
Cells with Data Validation
CellAllowCriteria
H2ListAmount,Percentage



Changing H2 & I2:

23 08 30.xlsm
ABCDEFGHI
1OriginalNewOriginalNewIncrease TypeIncrease
21616.1618.2618.4426Percentage1.01
3
4203205.03
5100101
Increase
Cell Formulas
RangeFormula
C2,F5,C4,F2C2=(B2+IF($H$2="Amount",$I$2,0))*IF($H$2="Amount",1,$I$2)
Cells with Data Validation
CellAllowCriteria
H2ListAmount,Percentage
 
Upvote 0
Solution
Thank you both. I'd rather not use VBA if I can help it, so I went with the formula option.

The amount part works, but not the percentage part. Not sure what I've got wrong (cell references updated for my sheet).

=J2+IF($I$1="Amount",$J$1,0)*IF($I$1="Amount",1,$J$1)

I also included a picture of the section in question
 

Attachments

  • Excel formula.PNG
    Excel formula.PNG
    4.8 KB · Views: 4
Upvote 0
Thank you both. I'd rather not use VBA if I can help it, so I went with the formula option.

The amount part works, but not the percentage part. Not sure what I've got wrong (cell references updated for my sheet).

=J2+IF($I$1="Amount",$J$1,0)*IF($I$1="Amount",1,$J$1)

I also included a picture of the section in question
Well that's silly. I flipped the addition and multiplication around for kicks and giggles, and now both work.

=J2*IF($I$1="Amount",1,$J$1)+IF($I$1="Amount",$J$1,0)
 
Upvote 0
Not sure what I've got wrong
You are missing a set of parentheses
=(J2+IF($I$1="Amount",$J$1,0))*IF($J$1="Amount",1,$J$1)

My original formula was
=(B2+IF($H$2="Amount",$I$2,0))*IF($H$2="Amount",1,$I$2)
 
Upvote 0
I see that you seem to have resolved this. However, your idea of doing the multiplication first is good too. (y)
 
Upvote 0
You are missing a set of parentheses
=(J2+IF($I$1="Amount",$J$1,0))*IF($J$1="Amount",1,$J$1)

My original formula was
=(B2+IF($H$2="Amount",$I$2,0))*IF($H$2="Amount",1,$I$2)
Those pesky parentheses. Thank you!
 
Upvote 0

Forum statistics

Threads
1,215,326
Messages
6,124,267
Members
449,149
Latest member
mwdbActuary

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