Вы находитесь на странице: 1из 2

13/09/2016 Excel VBA FormulaR1C1 Property ­ EASY Excel Macros

Excel  Easy
#1 Excel tutorial on the net Excel Introduction Basics Functions Data Analysis VBA 300 Examples Ask us

FormulaR1C1 Follow 19k Search Entire Site   Go

 
This example illustrates the difference between A1, R1C1 and R[1]C[1] style in Excel VBA.
Chapter  <   > 
1. Place a command button on your worksheet and add the following code line (A1 style):

Range("D4").Formula = "=B3*10" Create a Macro

Result:
Learn more, it's easy
Swap Values

Run Code from a Module

Macro Recorder

Use Relative References

FormulaR1C1

Add a Macro to the Toolbar

Macro Security

Protect Macro

Download Excel File
formulaR1C1.xls

Follow Excel Easy
2. Add the following code line (R1C1 style):
       
Range("D4").FormulaR1C1 = "=R3C2*10"

 
Result:

Explanation: cell D4 references cell B3 (row 3, column 2). This is an absolute reference ($ symbol in front of the
row number and column letter).

3. Add the following code line (R[1]C[1] style):

Range("D4").FormulaR1C1 = "=R[­1]C[­2]*10"

Result:

http://www.excel­easy.com/vba/examples/formulaR1C1.html 1/2
13/09/2016 Excel VBA FormulaR1C1 Property ­ EASY Excel Macros

Explanation: cell D4 references cell B3 (one row above and 2 columns to the left). This is a relative reference.
This code line gives the exact same result as the code line used at step 1.

4. Why learning about this? Because the Macro Recorder uses the FormulaR1C1 property (R[1]C[1] style). The
Macro Recorder creates the following code lines if you enter the formula =B3*10 into cell D4.

Explanation: you can see that this is the exact same code line used at step 3.

Do you like this free website? Please share this page on Google+
Share 7

6/9 Completed! Learn more about creating macros >
Go to Top: FormulaR1C1    |    Go to Next Chapter: MsgBox

COPYRIGHT (C) 2010­2016 WWW.EXCEL­EASY.COM. ALL RIGHTS RESERVED.
EXCEL 2010 TUTORIAL | HOW TO USE EXCEL | MICROSOFT EXCEL 2010 | VBA IN EXCEL

http://www.excel­easy.com/vba/examples/formulaR1C1.html 2/2

Вам также может понравиться