+ Reply to Thread
Results 1 to 8 of 8

Home or Ctrl-Home

  1. #1
    noyb
    Guest

    Home or Ctrl-Home

    Please tell me the VBA code for these keystrokes
    Thanks

  2. #2
    Chip Pearson
    Guest

    Re: Home or Ctrl-Home

    Home =
    Cells(ActiveCell.Row,"A").Select

    Ctrl+Home=
    Range("A1").Select


    --
    Cordially,
    Chip Pearson
    Microsoft MVP - Excel
    Pearson Software Consulting, LLC
    www.cpearson.com



    "noyb" <[email protected]> wrote in message
    news:[email protected]...
    > Please tell me the VBA code for these keystrokes
    > Thanks




  3. #3
    Norman Jones
    Guest

    Re: Home or Ctrl-Home

    Hi Noyb,

    Try:

    ActiveCell.EntireRow.Cells(1).Select

    Cells(1).Select

    However, using VBA, it is rarely necessary to make selections and it is
    frequently inefficient to do so.

    Noramally, a better approach would be to set the required cell to a range
    variable and manipulate the variable, e.g:

    Dim Rng as Range

    Set Rng = ActiveCell.EntireRow.Cells(1)
    Rng.Interior.ColorIndex = 6

    ---
    Regards,
    Norman



    "noyb" <[email protected]> wrote in message
    news:[email protected]...
    > Please tell me the VBA code for these keystrokes
    > Thanks




  4. #4
    noyb
    Guest

    Re: Home or Ctrl-Home

    Thanks, but, let me restate. I have a number of worksheets I want to
    cycle through and get the selected cell to the top left of the
    non-frozen part of each sheet. The number of frozen rows and columns
    differs from sheet to sheet. Is it possible to so this without having to
    hard code the location for each sheet. ie: the vba equivalent of
    "Ctrl+Home" with frozen panes.
    Thanks again

    Chip Pearson wrote:
    > Home =
    > Cells(ActiveCell.Row,"A").Select
    >
    > Ctrl+Home=
    > Range("A1").Select
    >
    >


  5. #5
    noyb
    Guest

    Re: Home or Ctrl-Home

    Actually don't want to select anything, just want to position cursor at
    top of sheet, taking into consideration frozen panes.
    Thanks

    Norman Jones wrote:
    > Hi Noyb,
    >
    > Try:
    >
    > ActiveCell.EntireRow.Cells(1).Select
    >
    > Cells(1).Select
    >
    > However, using VBA, it is rarely necessary to make selections and it is
    > frequently inefficient to do so.
    >
    > Noramally, a better approach would be to set the required cell to a range
    > variable and manipulate the variable, e.g:
    >
    > Dim Rng as Range
    >
    > Set Rng = ActiveCell.EntireRow.Cells(1)
    > Rng.Interior.ColorIndex = 6
    >
    > ---
    > Regards,
    > Norman
    >
    >
    >
    > "noyb" <[email protected]> wrote in message
    > news:[email protected]...
    >
    >>Please tell me the VBA code for these keystrokes
    >>Thanks

    >
    >
    >


  6. #6
    Charlie
    Guest

    Re: Home or Ctrl-Home

    It took me forever and a day to find this one...

    Cells(ActiveWindow.ActivePane.ScrollRow,
    ActiveWindow.ActivePane.ScrollColumn).Select



    "noyb" wrote:

    > Thanks, but, let me restate. I have a number of worksheets I want to
    > cycle through and get the selected cell to the top left of the
    > non-frozen part of each sheet. The number of frozen rows and columns
    > differs from sheet to sheet. Is it possible to so this without having to
    > hard code the location for each sheet. ie: the vba equivalent of
    > "Ctrl+Home" with frozen panes.
    > Thanks again
    >
    > Chip Pearson wrote:
    > > Home =
    > > Cells(ActiveCell.Row,"A").Select
    > >
    > > Ctrl+Home=
    > > Range("A1").Select
    > >
    > >

    >


  7. #7
    noyb
    Guest

    Re: Home or Ctrl-Home

    Well that was obvious!
    But seriously. Thanks a lot.

    Charlie wrote:
    > It took me forever and a day to find this one...
    >
    > Cells(ActiveWindow.ActivePane.ScrollRow,
    > ActiveWindow.ActivePane.ScrollColumn).Select
    >
    >
    >
    > "noyb" wrote:
    >
    >
    >>Thanks, but, let me restate. I have a number of worksheets I want to
    >>cycle through and get the selected cell to the top left of the
    >>non-frozen part of each sheet. The number of frozen rows and columns
    >>differs from sheet to sheet. Is it possible to so this without having to
    >>hard code the location for each sheet. ie: the vba equivalent of
    >>"Ctrl+Home" with frozen panes.
    >>Thanks again
    >>
    >>Chip Pearson wrote:
    >>
    >>>Home =
    >>>Cells(ActiveCell.Row,"A").Select
    >>>
    >>>Ctrl+Home=
    >>>Range("A1").Select
    >>>
    >>>

    >>


  8. #8
    cawatson
    Guest

    Re: Home or Ctrl-Home

    Charlie,

    This takes you to the top left of the "displayed" page but does not force to
    the same place that <Ctrl> <Home> does (the top/left corner of the "unfrozen"
    pane). My macro hides/reveals certain columns and I want to set the cursor
    the top/left of the "unfrozen" window as determined by the "Freeze Panes"
    command (i.e. regardless of where the cursor has been scrolled to and
    regardless of the presence/absence of hidden columns).

    I have tried to use SendKeys but am having difficulty get the code to work
    reliably given my limited knowledge/experience.

    Anyone have a suggestion?

    "Charlie" wrote:

    > It took me forever and a day to find this one...
    >
    > Cells(ActiveWindow.ActivePane.ScrollRow,
    > ActiveWindow.ActivePane.ScrollColumn).Select
    >
    >
    >
    > "noyb" wrote:
    >
    > > Thanks, but, let me restate. I have a number of worksheets I want to
    > > cycle through and get the selected cell to the top left of the
    > > non-frozen part of each sheet. The number of frozen rows and columns
    > > differs from sheet to sheet. Is it possible to so this without having to
    > > hard code the location for each sheet. ie: the vba equivalent of
    > > "Ctrl+Home" with frozen panes.
    > > Thanks again
    > >
    > > Chip Pearson wrote:
    > > > Home =
    > > > Cells(ActiveCell.Row,"A").Select
    > > >
    > > > Ctrl+Home=
    > > > Range("A1").Select
    > > >
    > > >

    > >


+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1