+ Reply to Thread
Results 1 to 6 of 6
  1. #1
    Registered User
    Join Date
    07-27-2009
    Location
    San Diego, CA
    MS-Off Ver
    Excel 2003
    Posts
    8

    Scroll to next sheet?

    Is there a macro out there that will automatically move the user to column A of the next sheet if they are on column IV and due a right arrow or scroll to the right? Also, if they are on column A and move to the left it will take them to column IV of the previous worksheet?

    Here's my problem... We're limited to Excel 2003 here at work and I have some data that is going to take over 600 columns by 8000 rows to display. It would be very cool to move between sheets by simply scrolling off the edge of one onto the next, either left or right.

  2. #2
    Forum Guru Andy Pope's Avatar
    Join Date
    05-10-2004
    Location
    Essex, UK
    MS-Off Ver
    2003 & 2007 & 2010
    Posts
    10,944

    Re: Scroll to next sheet?

    I suggest you keep columns A and IV clear of data

    code in the Thisworkbook object
    Code:
    Private Sub Workbook_SheetSelectionChange(ByVal Sh As Object, ByVal Target As Range)
    
        If Target.Column = Columns.Count Then
            ' move to next sheet
            If Sh.Index + 1 <= Worksheets.Count Then
                Application.Goto Worksheets(Sh.Index + 1).Cells(Target.Row, 2)
            Else
                Application.Goto Worksheets(1).Cells(Target.Row, 2)
            End If
        ElseIf Target.Column = 1 Then
            ' move to previous sheet
            If Sh.Index = 1 Then
                Application.Goto Worksheets(Worksheets.Count).Cells(Target.Row, Columns.Count - 1)
            Else
                Application.Goto Worksheets(Sh.Index - 1).Cells(Target.Row, Columns.Count - 1)
            End If
        End If
        
    End Sub
    Cheers
    Andy
    www.andypope.info

  3. #3
    Forum Guru JBeaucaire's Avatar
    Join Date
    03-21-2008
    Location
    Bakersfield, CA
    MS-Off Ver
    2010
    Posts
    18,225

    Re: Scroll to next sheet?

    1) On sheet1, don't use column IV, just put a header at the top that says "Next Page" or something like that.
    2) On sheet2, don't use column A, just put a header at the top that says "Previous Page" or something like that.
    3) Right-click on sheet1 tab and select VIEW CODE
    4) Paste in the worksheet event code into the module that appears:
    Code:
    Option Explicit
    
    Private Sub Worksheet_SelectionChange(ByVal Target As Range)
        If Target.Column = Columns.Count Then
            Sheets("Sheet2").Activate
            Sheets("Sheet2").Range("B1").Select
        End If
    End Sub
    5) Right-click on sheet2 tab and select VIEW CODE
    6) Paste in the worksheet event code into the module that appears:
    Code:
    Option Explicit
    
    Private Sub Worksheet_SelectionChange(ByVal Target As Range)
        If Target.Column = 1 Then
            Sheets("Sheet1").Activate
            Sheets("Sheet1").Cells(1, Columns.Count - 1).Select
        End If
    End Sub
    7) Close the VBEditor
    8) Save your sheet

    Now try scrolling off the right side of Sheet1 and it will switch you to column B of Sheet2. Try scrolling off the left of Sheet2 and it will switch you to the end of Sheet1....so you can just scroll back and forth.
    _________________
    Microsoft MVP 2010 - Excel
    Visit: Jerry Beaucaire's Excel Files & Macros

    If you've been given good help, use the icon below to give reputation feedback, it is appreciated.
    Always put your code between code tags. [CODE] your code here [/CODE]

    “None of us is as good as all of us” - Ray Kroc
    “Actually, I *am* a rocket scientist.” - JB (little ones count!)

  4. #4
    Forum Guru JBeaucaire's Avatar
    Join Date
    03-21-2008
    Location
    Bakersfield, CA
    MS-Off Ver
    2010
    Posts
    18,225

    Re: Scroll to next sheet?

    Andy, that is awesome!!
    _________________
    Microsoft MVP 2010 - Excel
    Visit: Jerry Beaucaire's Excel Files & Macros

    If you've been given good help, use the icon below to give reputation feedback, it is appreciated.
    Always put your code between code tags. [CODE] your code here [/CODE]

    “None of us is as good as all of us” - Ray Kroc
    “Actually, I *am* a rocket scientist.” - JB (little ones count!)

  5. #5
    Registered User
    Join Date
    07-27-2009
    Location
    San Diego, CA
    MS-Off Ver
    Excel 2003
    Posts
    8

    Re: Scroll to next sheet?

    That works pretty slick Andy! Thanks!

  6. #6
    Forum Guru JBeaucaire's Avatar
    Join Date
    03-21-2008
    Location
    Bakersfield, CA
    MS-Off Ver
    2010
    Posts
    18,225

    Re: Scroll to next sheet?

    If that takes care of your need, be sure to EDIT your original post, click Go Advanced and mark the PREFIX box [SOLVED].


    (Also, use the blue "scales" icon in our posts to leave Reputation Feedback, it is appreciated)
    _________________
    Microsoft MVP 2010 - Excel
    Visit: Jerry Beaucaire's Excel Files & Macros

    If you've been given good help, use the icon below to give reputation feedback, it is appreciated.
    Always put your code between code tags. [CODE] your code here [/CODE]

    “None of us is as good as all of us” - Ray Kroc
    “Actually, I *am* a rocket scientist.” - JB (little ones count!)

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.2.0