Forum Discussion

Larry1265's avatar
Larry1265
Copper Contributor
Jan 22, 2022
Solved

Macro

I want to create macros for very simple asks.  One such is to simply move the cursor down 8 rows on the spreadsheet.  I can't fathom MS macro instructions (EXCEL in 365).  Record macro.  Fine.  Dialog box.  Name the macro.  Assign a keyboard letter.  "OK".  Move the cursor down 8 rows.  Stop recording.  

Press {ctrl}d.  Cursor doesn't move.  Manually put the cursor elsewhere on the spreadsheet.  Press {ctrl}d.  Cursor goes the cell where it was when I pressed "stop recording".  Move the cursor somewhere else.  Press {ctrl}d.  Cursor jumps to that same cell.  I have created macros in EXCEL in the past, back in  2007.  They still work.  My background in macros is extensive - in LOTUS 123 - 35 years ago.  Microsoft instructions leave me scratching my head in puzzlement.  Puleeeze, give me some help here?

 

Larry

Email address removed

  • Larry1265 

    Macro recording defaults to absolute references and as such, selecting different cells without actions in between are optimized/omitted.

    Switching to Relative References merely gives you what you want in this case. The possibility is there like in the old days, but not looking the same as before.

     

    Sub Macro1()
        ActiveCell.Offset(8, 0).Range("A1").Select
    End Sub

     

5 Replies

  • bosinander's avatar
    bosinander
    Iron Contributor

    Larry1265 

    Macro recording defaults to absolute references and as such, selecting different cells without actions in between are optimized/omitted.

    Switching to Relative References merely gives you what you want in this case. The possibility is there like in the old days, but not looking the same as before.

     

    Sub Macro1()
        ActiveCell.Offset(8, 0).Range("A1").Select
    End Sub

     

  • NowshadAhmed's avatar
    NowshadAhmed
    Iron Contributor

    Perhaps when recording the Macro, you are not selecting the cell 8 rows below?
    Excel Macro doesn't record mouse cursor movements.

     

    EDIT: It seems the macro record is specific and not dynamic. So even if you record successfully, it will always move to the last cell you selected before stopping the record:

     

    Best Solution is what HansVogelaar observed.

  • Larry1265 

    This is a shortcoming of the macro recorder. It pays to learn a little bit about Excel VBA. The macro to move down 8 rows could look like this:

     

     

    Sub MoveDown8()
        ActiveCell.Offset(8).Select
    End Sub

     

     

Resources