Use property R1C1

2

I want to use the Range.Formula R1C1 property on a check copy form to fill in a nominal check. How could I use this property for this purpose?

I found a code described as follows:

Sub Para()
'
' Para Macro
' Macro gravada em 4/9/2006 por Fundação  Fé e Alegria
'
'
Range("D7:J14").Select

ActiveCell.FormulaR1C1 = "=R[-9]C"

Range("D15:

But I did not understand.

    
asked by anonymous 10.06.2014 / 10:55

1 answer

2

ActiveCell.FormulaR1C1 is for you to write to the selected cell. If you do:

Range("D7").Select
ActiveCell.FormulaR1C1 = "abc"

The macro selects cell D7 and writes abc to it.

In your example you have selected several rows and columns, but only wrote in the first of them, the D7.

Your macro causes the contents of the cell to be a formula that simply replicates the contents of another cell, because of = followed by a relative position. The relative position you wrote was R[-9]C which says that the address of the other cell is 9 lines and less than the current one, in the same column. R is an abbreviation of ROW, which means line. C is an abbreviation for COLUMN which means column.

9 lines less likely to cause undesirable behavior, since you're on line 7.

Correctly calculate the relative value of cell D7 and replace it in your macro. In addition, you can change Range("D7:J14").Select to Range("D7").Select , since it is not making a difference. If you intend to write in all fields in this range, redo your macro to copy cell by cell. Selecting a range has other utilities such as merge such cells.

Another example of relative cell calculation: R[-1]C[-2] , refers to one line less than two columns less.

    
10.06.2014 / 13:20