Move 2 cells to right

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

hi,
Please help.
In excel vba, what is the command to move the cursor.
Example: The cursor was in one cell and i want move it 2 cells to the left.

Thanks in advance.
 
Activecell.Offset(0,2).Select

--

HTH

RP
(remove nothere from the email address if mailing direct)
 
Sub Macro1()
Dim i As Long
Dim j As Long
j = Selection.Column
i = Selection.Row
Cells(i, j + 2).Select
End Sub

to move to an arbitrary place use
Cells(I+9,J+13).Select for example
 
You rarely need to select a cell or range of cells in VBA. Code is cleaner
and works FAR faster if you do not select cells.

To answer you question, though

activecell.offset(0,-2).select

Now, if you are selecting it because you want to copy it, or clear it, etc,
do this instead

activecell.offset(0,-2).copy
activecell.offset(0,-2).clear
activecell.offset(0,-2).pastespecial xlPasteAll
 

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

Back
Top