VBA "move" method?

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

Guest

Hi ...

I need to write (or record) a macro that will simply move the the visual
cursor a specified number of cells up, down, right, left rather than using a
cell reference.

For example, if I am at D5 and run the macro, the cursor will move down 5
rows to D10 (i.e., move down 5 rows); and if I run the same macro when the
cursor is at K10, the cursor will skip down to K15.

Does anyone have some sample code you can share that shows the syntax for
up, down, right, left movement by a specified number of cells?

Thanks so much for yoru help ...

Bill Morgan
 
message
Hi ...

I need to write (or record) a macro that will simply move the the
visual cursor a specified number of cells up, down, right, left
rather than using a cell reference.

For example, if I am at D5 and run the macro, the cursor will move
down 5 rows to D10 (i.e., move down 5 rows); and if I run the same
macro when the cursor is at K10, the cursor will skip down to K15.

Does anyone have some sample code you can share that shows the syntax
for up, down, right, left movement by a specified number of cells?

Thanks so much for yoru help ...

Bill Morgan

Try this:

Sub Move()
ActiveCell.Offset(5, 0).Activate
End Sub


HTH,

Alan.
 
Activecell.Offset(5,0).Select 'down

Activecell.Offset(0,5).Select 'Right

If Activecell.Column>5 then
activecell.offset(0,-5).select 'left
endif

if Activecell.Row >5 Then
.Activecell..Offset(-5,0).Select 'up
End If

--

HTH

RP
(remove nothere from the email address if mailing direct)
 
Bob,

This worked perfectly, as well.
Both of the responses I received to this question have turned me on to
getting more into Excel objects/properties/methods. I hadn't realized how
powerful (and simple) a little more typing and a little less "recording"
could be.

Thanks again ...
 

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