• VBA equivalent of CTRL+HOME

    Author
    Topic
    #478297

    I would like include cursor movement in a macro so that the visible range of the worksheet resets and places the cursor in a specific cell. The macro would start above and left of the freeze-point of frozen panes and then end up down and right of the freeze-point.

    When I recorded the manual steps the macro shows:
    ActiveCell.SpecialCells(xlLastCell).Select
    Range(“J19”).Select

    I would rather not use an absolute cell reference like J19. In fact, to get there I used the key combo CTRL+HOME.

    Whats the VBA equivalent of CTRL+HOME?

    Viewing 1 reply thread
    Author
    Replies
    • #1292261

      How about this?

      Steve

      Code:
      Sub CtrlHome()
        Application.Goto Range("A1"), True
        ActiveWindow.VisibleRange(1, 1).Select
      End Sub
      • #1292282

        Steve,

        A1 may not necessarily be the equivalent of CTRL+Home if panes have been frozen, it could quite easily be something like B5. I would like to know the VBA equivalent too as I use the frozen panes feature quite a lot on my larger worksheets.

        • #1292303

          Did you try the code. There are 2 lines to it….

          The 2nd line without going to A1 first, would get you to the upper left part of the pane in the current window, not the one at the start of the worksheet

          Steve

          • #1292547

            Steve, Thanks for that I confess I didn’t look at line 2. This code will be very useful for me, as I have a lot of very large spreadsheets with the first few rows frozen so that users always see the header rows.

    • #1292292

      Something like:

      Code:
      Sub scrollpane()
         With ActiveWindow
            .ScrollRow = 1
            .ScrollColumn = 1
            .ActivePane.VisibleRange.Cells(1).Select
         End With
      End Sub
      
    Viewing 1 reply thread
    Reply To: VBA equivalent of CTRL+HOME

    You can use BBCodes to format your content.
    Your account can't use all available BBCodes, they will be stripped before saving.

    Your information: