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.
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
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:
5) Right-click on sheet2 tab and select VIEW CODECode: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
6) Paste in the worksheet event code into the module that appears:
7) Close the VBEditorCode: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
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 theicon 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!)
Andy, that is awesome!!
_________________
Microsoft MVP 2010 - Excel
Visit: Jerry Beaucaire's Excel Files & Macros
If you've been given good help, use theicon 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!)
That works pretty slick Andy! Thanks!
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 theicon 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!)
There are currently 1 users browsing this thread. (0 members and 1 guests)
Bookmarks