View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
Gixxer_J_97[_2_] Gixxer_J_97[_2_] is offline
external usenet poster
 
Posts: 206
Default How do I write macros with relative reference cells

Hi John

if you are working with formulas you have a couple ways of doing it
r1c1
and r[1]c[1]
or a mix
r1c[1]

r1c1 will refer to $A$1
r[1]c[1] will be used as an offset, 1 row, 1 column offset

eg
activecell.formular1c1="=r1c1"
will give you the formula = "=$A$1"
activecell.formular1c1="=r[1]c[1]"
will give you the formula (if activecell is b1)
"=c2"


hth

J




"trilogylynch" wrote:

I have written a macro , basically a black sholels model for random
simmulation, that works only as long as I do not change the spread sheet
after the macro is recorded.

If I add or delete a row or column, then the macro blows up. I believe the
problem is that the cell references in the macro are specific to each cell
when recorded.

Is there a way around this problem?


John Lynch