+ Reply to Thread
Results 1 to 8 of 8

Scroll to top of page code

  1. #1
    Forum Contributor
    Join Date
    12-16-2005
    Posts
    161

    Scroll to top of page code

    I have a worksheet where the first 6 rows are 'frozen'

    When a worksheet is activated, I would like the sheet to be 'scrolled' to the top. Tired Range.("A7").select, however the worksheet does not scroll to the top.

    Would appreciate anyone helping with the suggested code to make this happen.

    Cheers

    Peter (new to VBA)

  2. #2
    Mark Lincoln
    Guest

    Re: Scroll to top of page code

    Enter this code in the sheet in question:

    Private Sub Worksheet_Activate()
    Range("A7").Select
    End Sub


  3. #3
    Forum Contributor
    Join Date
    12-16-2005
    Posts
    161
    Hi Mark, I've tried that, the cursor moves to the cell, but the page doesn't 'scroll up' for some reason...

    Cheers

    Peter

  4. #4
    Norman Jones
    Guest

    Re: Scroll to top of page code

    Hi Peter,

    Try:

    '=============>>
    Private Sub Worksheet_Activate()
    Application.Goto Reference:=Range("A7"), Scroll:=True
    End Sub
    '<<=============

    This is worksheet event code and should be pasted into the worksheets's code
    module (not a standard module and not the workbook's ThisWorkbook module):

    Right-click the worksheet's tab
    Select 'View Code' from the menu and paste the code.
    Alt-F11 to return to Excel.


    ---
    Regards,
    Norman


    "peter.thompson"
    <[email protected]> wrote in
    message news:[email protected]...
    >
    > I have a worksheet where the first 6 rows are 'frozen'
    >
    > When a worksheet is activated, I would like the sheet to be 'scrolled'
    > to the top. Tired Range.("A7").select, however the worksheet does not
    > scroll to the top.
    >
    > Would appreciate anyone helping with the suggested code to make this
    > happen.
    >
    > Cheers
    >
    > Peter (new to VBA)
    >
    >
    > --
    > peter.thompson
    > ------------------------------------------------------------------------
    > peter.thompson's Profile:
    > http://www.excelforum.com/member.php...o&userid=29686
    > View this thread: http://www.excelforum.com/showthread...hreadid=501532
    >




  5. #5
    Forum Contributor
    Join Date
    12-16-2005
    Posts
    161

    Thanks

    Thanks Norman, that did it.

    Cheers

    Peter

  6. #6
    Mark Lincoln
    Guest

    Re: Scroll to top of page code

    Peter, I'm puzzled -- I get the same behavior both with my code and
    with Norman's, and I've never had mine fail in use in any worksheet in
    which I've used it.

    I'm curious as to why my code didn't work for you. Did you run it in
    the worksheet's code module?


  7. #7
    Forum Contributor
    Join Date
    12-16-2005
    Posts
    161
    Hi Mark,

    Am doing a few other things at the same time, see code below. Probably why it isn't working in this scenario. Unfortunately I'm too much of a newbie to figure out why!

    Sincerely appreciate your asistance.

    Public Sub Worksheet_Activate()
    Application.ScreenUpdating = False
    Password = "djdog"
    ActiveSheet.Unprotect Password
    Cells.Select
    Selection.EntireRow.Hidden = False
    Application.Goto Reference:=Range("A7"), Scroll:=True


    Cheers

    Peter

  8. #8
    Mark Lincoln
    Guest

    Re: Scroll to top of page code

    > Public Sub Worksheet_Activate()
    > Application.ScreenUpdating = False
    > Password = "djdog"
    > ActiveSheet.Unprotect Password
    > Cells.Select
    > Selection.EntireRow.Hidden = False
    > Application.Goto Reference:=Range("A7"), Scroll:=True


    Peter, I don't know for sure, but I'd think turning off ScreenUpdating
    is keeping your original code from working. I've never needed to keep
    the screen from updating while using my code. Norman's code forces the
    scrolling where your original code (and mine) do not.


+ 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