How to write macro that selects relative locations

N

NewKid

I am using the macro recorder and have it turns to RELATIVE recording rather
than ABSOLUTE recording, but... I cannot figure out how to record navigation
keys relative to my current location. For example, when I press the HOME
key, I want the macro to just go to the far left column for the current row.
When I press the UP ARROW, I want the macro to move up one cell from the
current location. Even with the RELATIVE recording on, it still puts
absolute references in the macro.

How can I get around this? THANKS IN ADVANCE FOR ANY HELP YOU CAN OFFER!
 
B

Bernie Deitrick

To select the first column of the activecell's row (similar to Home)

Cells(Activecell.Row,1).Select

To move up one cell: ActiveCell.Offset(-1,0).Select
To move down one cell: ActiveCell.Offset(1,0).Select
To move right one cell: ActiveCell.Offset(0,1).Select
To move left one cell: ActiveCell.Offset(0, -1).Select

But you rarely need to select anything....

HTH,
Bernie
MS Excel MVP
 
N

NewKid

Thank you! Worked perfectly!

Bernie Deitrick said:
To select the first column of the activecell's row (similar to Home)

Cells(Activecell.Row,1).Select

To move up one cell: ActiveCell.Offset(-1,0).Select
To move down one cell: ActiveCell.Offset(1,0).Select
To move right one cell: ActiveCell.Offset(0,1).Select
To move left one cell: ActiveCell.Offset(0, -1).Select

But you rarely need to select anything....

HTH,
Bernie
MS Excel MVP
 

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