Modify an Excel Cell Only When a Condition Is Met
Question details
Update an Excel cell when a condition is met and retain or reproduce its existing value otherwise.

- Product
- Microsoft Excel
- Device & OS
- not provided
- Scenario
- A worksheet should change a cell's value only when a specified condition is true.
- Observed behavior
- A formula can return a conditional result, but it cannot retain an arbitrary previous manual value when the condition is false.
Identify the condition cell, the cell to update, and where the new value comes from. Determine whether the value needed when the condition is false can be recalculated from another cell or must be preserved as an arbitrary manual entry.
Use an IF Formula When the Original Value Can Be Recalculated
Use a formula if the value needed when the condition is false is available from another cell or calculation.
For example, use A2 for the condition, C2 for the new value, and D2 for the value to show when the condition is false.
Select B2 and enter =IF(A2="Yes",C2,D2). B2 displays C2 when A2 is Yes and D2 otherwise.
Change A2 between Yes and another value and check that B2 displays the expected result.
Use a Worksheet_Change Macro to Preserve a Manual Value
Use a worksheet event macro when the existing value is a manual entry that cannot be reconstructed by a formula.
Use WPS Spreadsheets for Conditional Formulas
WPS Office is a free, lightweight alternative with a familiar interface for working with spreadsheet formulas. Open compatible Excel files to migrate everyday spreadsheet work easily; Excel VBA event behavior may require Microsoft Excel.

Frequently Asked Questions
Can an Excel formula keep a cell's previous manual value?
An ordinary formula cannot preserve an arbitrary previous manual value in the same cell. Use an IF formula if the fallback value can be calculated elsewhere, or use a VBA event macro if it must remain unchanged.
Where should I put the Worksheet_Change code?
In desktop Excel, right-click the worksheet tab, select View Code, and place the event procedure in that worksheet's code window. If a Worksheet_Change procedure already exists, combine the logic with it.
Why doesn't the macro run when a formula result changes?
Worksheet_Change responds to cell edits, not changes caused solely by formula recalculation. For a recalculation-driven condition, consider a Worksheet_Calculate event and account for repeated recalculations.
What file format should I use for the VBA solution?
Choose File > Save As and save the workbook as an Excel Macro-Enabled Workbook (*.xlsm). When reopening it, enable macros only if you trust the file.





