VBA & Macro Problems

How to Use R1C1 References Correctly in VBA FormulaR1C1

Maira MehtabMaira Mehtab Nov 10, 2026 871 views

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.

How to Correctly Use R1C1 References in VBA FormulaR1C1
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.
Before you start

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.

Solution 1Recommended

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.

1
Open the VBA Editor

Press Alt + F11 to open the VBA Editor and locate the module containing your formula script.

2
Locate Address Declarations

Find the code lines where you declare the .Address for your external range variables (for example, MDART_G2.Address).

3
Modify the ReferenceStyle Parameter

Add the parameter ReferenceStyle:=xlR1C1 inside the parenthesis. The updated code should look like this: MDART_G2.Address(External:=True, ReferenceStyle:=xlR1C1).

4
Format Relative References

Ensure any relative row or column offsets manually typed in the formula string use standard R1C1 syntax (such as RC[-1]).

5
Test the Macro

Run the macro to verify the INDEX/MATCH formula is successfully constructed and inserted into the target cells.

Apply the xlR1C1 Reference Style to External Addresses
Variables Updated: Forcing xlR1C1 ensures the macro parses external workbook addresses seamlessly inside a FormulaR1C1 property without triggering a syntax error.
Advanced Macro Support

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. 1. Install WPS Office: Download and install WPS Office from the official website to your computer.
  2. 2. Open Your Macro File: Launch WPS Spreadsheets and open your existing macro-enabled workbook (.xlsm).
  3. 3. Access the VBA Editor: Navigate to the 'Developer' tab on the ribbon and click 'Visual Basic' to open the VBA Editor.
  4. 4. Edit and Run: Modify your FormulaR1C1 syntax directly in the editor and click 'Run' to execute your macro instantly.
Fully compatible with Microsoft Excel VBA scripts and macro-enabled files.Supports complex FormulaR1C1, Formula2, and external workbook referencing.Lightweight architecture ensures fast processing for large datasets and heavy macro operations.Free to download and use with a highly familiar user interface.
microsoft office alternative - wps office

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.