Excel Macro - Moving cursor in Worksheet

  • Thread starter Thread starter Stephen King
  • Start date Start date
S

Stephen King

I am writing a macro and cannot find any command that will
allow me to move the cursor in the Worksheet. Rather than
give a Cell address such as "A3" I want to be able to move
the cursor any given number of cells to the right,left, up
or down.
Can anyone help?
 
activecell.offset(x,y).select

will move x rows down (if positive, up if negative) and y columns to the right
(if positive, left if negative).
 
Another thing you may find very useful is:

range(selection.end(xldown)).select
has the same result as ctl+down in the spreadsheet, or

range(selection, selection.end(xldown)).select
has the same result as ctl+shft+down in the spreadsheet

Likewise with xlup, xltoright, xltoleft.

Note: if your current range is a single cell, it will do
what you instinctively expect. If your current range is,
say, an entire row, xldown will select entire rows and so
on.

Nikos Y.
 
Back
Top