Formula Errors

Use a User-Specified Operator in an Excel Formula

Phi Hung VoPhi Hung Vo Nov 20, 2026 868 views

Question details

The user wants an Excel formula to apply an operator and adjustment supplied in separate cells to a calculated value.

Use a User-Specified Operator in an Excel Formula
Product
Microsoft Excel
Device & OS
not provided
Scenario
A worksheet needs to adjust a base calculation using a user-selected arithmetic operator and number.
Observed behavior
An operator entered as text is not evaluated automatically, and referring to the result cell in its own calculation can create a circular reference.
Before you start

Identify the formula that produces the base value and choose separate cells for the operator, adjustment, and final result. The example below uses A2 for the base value, B2 for the operator, C2 for the adjustment, and D2 for the result.

Solution 1Recommended

Apply the Operator with a Nested IF Formula

Use separate cells and IF logic to handle addition, subtraction, multiplication, and division without a circular reference.

1
Enter the base calculation

In A2, enter the existing base formula or a numeric value. Make sure the formula in A2 does not depend on D2.

2
Enter the operator and adjustment

In B2, enter +, -, *, or / as text. If Excel treats the entry as a formula, prefix it with an apostrophe, such as '+. Enter the numeric adjustment in C2.

3
Calculate the adjusted result

Select D2 and enter =IF(B2="+",A2+C2,IF(B2="-",A2-C2,IF(B2="*",A2*C2,IF(B2="/",IF(C2=0,"Cannot divide by zero",A2/C2),"Invalid operator")))).

4
Test the inputs

Change B2 and C2 to check the result in D2. An unsupported operator returns "Invalid operator"; division by zero returns a warning.

Apply the Operator with a Nested IF Formula
Keeping the result in one cell: If the final result must appear in the original base cell, incorporate the original base formula into the adjustment formula instead of referencing that cell itself. Alternatively, calculate the base in a helper cell. A VBA function does not eliminate a circular reference if the formula still depends on its own result.
Calculate with WPS Spreadsheets

Apply a User-Entered Operator in WPS Spreadsheets

Use the same nested IF approach in WPS Spreadsheets to apply a text operator and adjustment to a base value without referring to the result cell.

  1. 1. Open the spreadsheet: Open WPS Spreadsheets and select your workbook, or create a blank spreadsheet.
  2. 2. Enter the inputs: Enter a base value or formula in A2, a text operator in B2, and a numeric adjustment in C2. If needed, prefix the operator with an apostrophe, such as '+.
  3. 3. Add the formula: Select D2 and enter =IF(B2="+",A2+C2,IF(B2="-",A2-C2,IF(B2="*",A2*C2,IF(B2="/",IF(C2=0,"Cannot divide by zero",A2/C2),"Invalid operator")))).
  4. 4. Check and save: Change the operator or adjustment to verify D2, then use File > Save As to save the workbook as an XLSX file.
Apply four arithmetic operators with a single formulaAvoid circular references by separating the base and result cellsOpen and save Microsoft Excel XLSX filesUse WPS Office for free
microsoft office alternative - wps office

Frequently Asked Questions

Can Excel use an operator stored as text directly in a formula?

No. A formula must use logic such as IF or SWITCH to compare the text with supported operators and perform the corresponding calculation.

Why does my adjustment formula cause a circular reference?

It may refer to its own result cell, directly or through another formula. Put the base calculation in a helper cell, or include the original base expression in the final formula without referencing the final cell.

How can I prevent a division-by-zero error?

Check the adjustment cell before dividing. For example, IF(C2=0,"Cannot divide by zero",A2/C2) returns a message when C2 is zero.

Can I use a VBA function for the operator logic?

Yes. You can place a user-defined function in a standard module in the workbook so its worksheets can use it. The formula must still avoid depending on its own result, or it can create a circular reference.