VBA coding

  • Thread starter =?iso-8859-1?B?RWzpbmE=?=
  • Start date
?

=?iso-8859-1?B?RWzpbmE=?=

Why do the cell references in part of the macro below
include negative numbers?


ActiveCell.FormulaR1C1 = "=RC[-2]-RC[-3]"
Range("C5").Select
 
H

Harry

The cells are reference as R1, C1 - It's like offset from the activecell.

ActiveCell.FormulaR1C1 = "=RC[-2]-RC[-3]"

This could also be interpreted as this

ActiveCell.Formula = "=B2+B3"

If you want to see this type of refernce on your worksheet, goto menu bar

TOOLS > Options

Click the General tab, you will see the R1C1 reference style.

This type is useful, when you want to calculate / move to cells based on
your current location.

Hope this helps

Hari

Eléna said:
Why do the cell references in part of the macro below
include negative numbers?


ActiveCell.FormulaR1C1 = "=RC[-2]-RC[-3]"
Range("C5").Select
 
T

Tom Ogilvy

The interpretation would depend on what cell the formula is place in, but
since the rows are absolute and the columns relative, I don't know of any
cell where it would be interpreted as =B2+B3, particularly since the formula
does subtraction rather than addition

ActiveCell.FormulaR1C1 = "=RC[-2]-RC[-3]"

if the activeCell is D5 would be equivalent to =B5-A5

--
Regards,
Tom Ogilvy

Harry said:
The cells are reference as R1, C1 - It's like offset from the activecell.

ActiveCell.FormulaR1C1 = "=RC[-2]-RC[-3]"

This could also be interpreted as this

ActiveCell.Formula = "=B2+B3"

If you want to see this type of refernce on your worksheet, goto menu bar

TOOLS > Options

Click the General tab, you will see the R1C1 reference style.

This type is useful, when you want to calculate / move to cells based on
your current location.

Hope this helps

Hari

Eléna said:
Why do the cell references in part of the macro below
include negative numbers?


ActiveCell.FormulaR1C1 = "=RC[-2]-RC[-3]"
Range("C5").Select
 
G

Guest

hi
In the example below, R stands for Row and C stands for
column.
Positive number For R mean down negative number mean up.
Positive number for c mean left negative number mean right
so RC[-2] means zero rows up/down and 2 columns to left.
if R[1]C[2] then
one row down and 2 column right.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top