How to Use R1C1 References Correctly in VBA FormulaR1C1
Question details
The user needs to fix a VBA macro that uses the FormulaR1C1 property but fails when combining external range references with functions like INDEX and MATCH.

- Product
- Spreadsheets
- Device & OS
- not provided
- Scenario
- Writing a VBA macro to insert an INDEX/MATCH formula that dynamically references an external workbook's data ranges.
- Observed behavior
- The macro fails or returns an error because the formula string mixes the FormulaR1C1 property with A1-style external range references instead of matching the required R1C1 reference style.
Ensure your VBA editor is open and you have a backup of the workbook containing the macro. Verify the names and paths of the external workbooks you are referencing to avoid path-related errors.
Apply the xlR1C1 Reference Style to External Addresses
Use this method to keep the FormulaR1C1 property by forcing your external range address variables to output in R1C1 notation.
The FormulaR1C1 property strictly expects references to be in the R1C1 format. When you pull the address of an external range in VBA, it defaults to the standard A1 format. You must explicitly tell the Address property to output R1C1 styling so it matches what FormulaR1C1 expects.
Press Alt + F11 to open the VBA Editor and locate the module containing your formula script.
Find the code lines where you declare the .Address for your external range variables (for example, MDART_G2.Address).
Add the parameter ReferenceStyle:=xlR1C1 inside the parenthesis. The updated code should look like this: MDART_G2.Address(External:=True, ReferenceStyle:=xlR1C1).
Ensure any relative row or column offsets manually typed in the formula string use standard R1C1 syntax (such as RC[-1]).
Run the macro to verify the INDEX/MATCH formula is successfully constructed and inserted into the target cells.

Switch to the Standard Formula Property
If you prefer writing standard A1-style references, switch the VBA property to accept standard notations instead of trying to convert them to R1C1.
Write and Execute VBA Macros Seamlessly in WPS Spreadsheets
WPS Office provides robust support for VBA macros, allowing you to automate tasks and use advanced programming properties like FormulaR1C1 just as you would in Microsoft Excel.
- 1. Install WPS Office: Download and install WPS Office from the official website to your computer.
- 2. Open Your Macro File: Launch WPS Spreadsheets and open your existing macro-enabled workbook (.xlsm).
- 3. Access the VBA Editor: Navigate to the 'Developer' tab on the ribbon and click 'Visual Basic' to open the VBA Editor.
- 4. Edit and Run: Modify your FormulaR1C1 syntax directly in the editor and click 'Run' to execute your macro instantly.

Frequently Asked Questions
What is the difference between Formula and FormulaR1C1 in VBA?
The .Formula property expects standard A1-style cell references (like A1 or $B$2). In contrast, the .FormulaR1C1 property requires the R1C1 notation (like R1C1 or R[1]C[-1]). Mixing the two within the same property call will cause an application-defined runtime error.
Why does my external reference Address return A1 style by default?
In VBA, the Range.Address property is designed to return the A1 notation by default as it is the most common use case. If you need it to return R1C1 format, you must explicitly specify ReferenceStyle:=xlR1C1 within the Address parameters.
Can I use Formula2 for dynamic arrays in macros?
Yes, .Formula2 is used to handle dynamic array formulas that are capable of spilling results into adjacent empty cells. If you need dynamic spilling capabilities alongside R1C1 notation, you should use the .Formula2R1C1 property.




