Scottie P
07-21-2004, 09:25 AM
Since the topic of a 'back button' came up in another thread I thought that I would put this one out there as well. Again, I know that this is another shameless lifting from somewhere...
The two subs below will move the user through worksheets forward or backward, but there is a snag with this one: if there are hidden sheets we do a Runtime '1004' : Select method of Worksheet class failed.
' Move Forward
Sub goFwd()
On Error Resume Next
ActiveSheet.Next.Select
If Err.Number <> 0 Then
Sheets(1).Select
Err.Clear
End If
On Error GoTo 0
End Sub
' Move Backward
Sub goBk()
On Error Resume Next
ActiveSheet.Previous.Select
If Err.Number <> 0 Then
Sheets(Sheets.Count).Select
Err.Clear
End If
On Error GoTo 0
End Sub
Rather than keep this as is, can we set this up as global - I could create a CommandBar for this one.
Why not use Sheet tabs or Cntl + PageUp/PageDown, etc...? Because sometimes custom apps won't allow it...plus it would be a fun gizmo to have, of course! :*)
Scott
The two subs below will move the user through worksheets forward or backward, but there is a snag with this one: if there are hidden sheets we do a Runtime '1004' : Select method of Worksheet class failed.
' Move Forward
Sub goFwd()
On Error Resume Next
ActiveSheet.Next.Select
If Err.Number <> 0 Then
Sheets(1).Select
Err.Clear
End If
On Error GoTo 0
End Sub
' Move Backward
Sub goBk()
On Error Resume Next
ActiveSheet.Previous.Select
If Err.Number <> 0 Then
Sheets(Sheets.Count).Select
Err.Clear
End If
On Error GoTo 0
End Sub
Rather than keep this as is, can we set this up as global - I could create a CommandBar for this one.
Why not use Sheet tabs or Cntl + PageUp/PageDown, etc...? Because sometimes custom apps won't allow it...plus it would be a fun gizmo to have, of course! :*)
Scott