Fix Excel VBA AutoFill Repeating the Same Formula Result
Question details
The user needs to correct a VBA macro that fills down the same formula result instead of dynamically calculating row by row.

- Product
- Microsoft Excel
- Device & OS
- not provided
- Scenario
- Running an Excel VBA macro that uses AutoFill and the SUBSTITUTE function to populate a column.
- Observed behavior
- The macro copies the exact value from the first row into all subsequent rows instead of calculating the formula uniquely for each row.
Ensure your worksheet's data range has the correct number of rows and back up your VBA code before making any script modifications.
Apply Formula Directly Using FormulaR1C1 and Enable Automatic Calculation
Bypassing the traditional AutoFill method and directly injecting the formula across the range is more efficient and prevents static value replication.
When an Excel VBA AutoFill repeats the same result, it is often due to the workbook's Calculation Options being set to 'Manual', or the AutoFill method not parsing relative references dynamically enough. Using the FormulaR1C1 property assigns the formula to the entire range simultaneously, inherently adjusting relative row and column references without needing a loop.
Press ALT + F11 to open the Visual Basic for Applications (VBA) Editor and locate your macro module.
Find the section of your code using AutoFill. Replace it with a direct range formula assignment. For example: Range("E2:E" & LastRow2).FormulaR1C1 = "=SUBSTITUTE(RC[-1],CHAR(10),"" "")".
Return to your Excel worksheet. Go to the 'Formulas' tab on the top ribbon.
Click on 'Calculation Options' in the Calculation group and ensure 'Automatic' is checked. If it is set to 'Manual', formulas will not recalculate when filled down.

Write and Run VBA Macros Seamlessly in WPS Spreadsheet
WPS Office Spreadsheet provides a built-in VBA editor that is fully compatible with Excel's macro scripts. You can easily apply the FormulaR1C1 method or AutoFill functions directly within WPS to automate your data processing without repeating values.
- 1. Open your Macro-Enabled Workbook: Launch WPS Spreadsheet and open your existing .xlsm file containing the AutoFill macro.
- 2. Access the VBA Editor: Navigate to the 'Tools' tab on the ribbon and click on 'Macros' to launch the Visual Basic Editor.
- 3. Edit and Run the Code: Replace the AutoFill section with the Range.FormulaR1C1 method. Ensure 'Calculation' is set to Automatic in the Formulas tab, then hit F5 to run your macro flawlessly.

Frequently Asked Questions
Why does Excel AutoFill copy the same value instead of calculating the formula?
This usually happens when the 'Calculation Options' in Excel are set to 'Manual'. In manual mode, formulas are not recalculated as they are copied down, resulting in the display of the first row's calculated value in all subsequent cells.
What is the difference between Formula and FormulaR1C1 in VBA?
The .Formula property uses standard A1 reference style (e.g., A2, B5), which can remain static unless coded dynamically. The .FormulaR1C1 property uses relative row and column notation (e.g., R[1]C[-1]), making it much easier to apply a consistent relative formula across a large range of cells without needing to loop through each row.
How do I force a recalculation in an Excel VBA macro?
You can force a recalculation in your VBA code by adding the command 'Application.Calculate' after your formula is applied, or by ensuring automatic calculation is enabled using 'Application.Calculation = xlCalculationAutomatic'.
Can I use the SUBSTITUTE function across a full column in VBA?
Yes. While the worksheet SUBSTITUTE function doesn't always natively spill like dynamic arrays in older Excel versions, applying it via VBA using .FormulaR1C1 across a specific range effectively bypasses this limitation, writing the proper formula to each individual cell.




