ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   VBA "move" method? (https://www.excelbanter.com/excel-programming/317662-vba-move-method.html)

bill_morgan_3333

VBA "move" method?
 
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

Alan

VBA "move" method?
 
"bill_morgan_3333" wrote in
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.



Bob Phillips[_6_]

VBA "move" method?
 
Activecell.Offset(5,0).Select 'down

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

If Activecell.Column5 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)


"bill_morgan_3333" wrote in
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




bill_morgan_3333

VBA "move" method?
 
Alan,

Simple, and it worked perfectly. Thanks ...

"Alan" wrote:

"bill_morgan_3333" wrote in
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.




bill_morgan_3333

VBA "move" method?
 
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 ...

"Bob Phillips" wrote:

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

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

If Activecell.Column5 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)


"bill_morgan_3333" wrote in
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






All times are GMT +1. The time now is 05:23 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com