How to make a macro with relative references

H

Hall

I need to make a macro that when I run it, it always starts at the cell from
where the cursor is. From that starting position, it moves 2 cells to the
left and does something.

I can't seem to do that. When I look at the code, it seems to have
hard-coded movement to the cell that I recorded the macro.

So how do I get the macro's code to use cell navigation relative to the cell
I run the macro?
 
D

Dave Peterson

Activecell.offset(0,-2).value = "hi there"

would put the text "hi there" in the cell two cells to the left of the
activecell.
 
P

Paul B

Hall, when you start recording the macro put it in relative reference, click
the button next to stop recording

--
Paul B
Always backup your data before trying something new
Please post any response to the newsgroups so others can benefit from it
Feedback on answers is always appreciated!
Using Excel 2002 & 2003
 
P

Pete_UK

When you record the macro you will see an small panel which has a stop
button on it and an icon next to it which is for selecting relative
movements - click this once for relative and again for absolute (it
toggles). In relative mode the button seems to be depressed, though
this is not very clear.

Hope this helps.

Pete
 
H

Hall

This seemed very promising but as many times as I've tried it, the relative
setting doesn't seem to be catching.

Can you or someone tell me what the code is supposed to be when relative?

That is, if my macro is using absolute, can I change something simple in the
code to make it use relative??
 
Top