ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Discussion (Misc queries) (https://www.excelbanter.com/excel-discussion-misc-queries/)
-   -   moving the cursor in a macro (https://www.excelbanter.com/excel-discussion-misc-queries/234229-moving-cursor-macro.html)

Amanda

moving the cursor in a macro
 
How do I move up one cell from where the cursor is in a macro (which could be
a random location in a workbook).
I don't want the cursor to be in a fixed location.
For example, if the cursor was in A4 before I run the macro. I want the
macro to move the cursor to A3. If the cursor was in B12 before I run the
macro, I want the cursor to move to B11.

p.s. I've tried using the arrow key as well as Shift Enter neither works.

Amanda

JE McGimpsey

moving the cursor in a macro
 
the macro recorder only records the results of your actions, not the
steps or keypresses.

One way:

Put this in as the first lines of your macro:

With ActiveCell
If .Row = 1 Then Exit Sub
.Offset(-1, 0).Activate
End With



In article ,
Amanda wrote:

How do I move up one cell from where the cursor is in a macro (which could be
a random location in a workbook).
I don't want the cursor to be in a fixed location.
For example, if the cursor was in A4 before I run the macro. I want the
macro to move the cursor to A3. If the cursor was in B12 before I run the
macro, I want the cursor to move to B11.

p.s. I've tried using the arrow key as well as Shift Enter neither works.

Amanda



All times are GMT +1. The time now is 02:06 AM.

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