PDA

View Full Version : scrolling through sheets



lior03
08-13-2008, 02:18 AM
hello
my aim is to allow the user scroll through all sheets.i want to let the user decide whether he wants to remain where he got of go on scrolling.i want to eliminate the beep sound every time the user move to a new sheet.and finaly iwant to learn how to do the opposite- go to next sheet
thanks

Sub selectsheet()
On Error GoTo err
ActiveSheet.Previous.Select
MsgBox "you entered - " & ActiveSheet.name, vbInformation, _
"this w.b contains " & ActiveWorkbook.Sheets.Count & " - sheets"
Exit Sub
err:
MsgBox " you reached the first sheet - " & ActiveSheet.name, vbCritical, _
"this w.b contains " & ActiveWorkbook.Sheets.Count & " - sheets"
End Sub


thanks

OTWarrior
08-13-2008, 02:55 AM
Isn't this excel? or are you using Access to automate Excel?

lior03
08-13-2008, 03:12 AM
maybe:

Sub selectprevious()
On Error GoTo err
Dim again As Boolean
Do While again = True
ActiveSheet.Previous.Select
If MsgBox("you entered - " & ActiveSheet.name & "more?", vbInformation + vbYesNo, _
"this w.b contains " & ActiveWorkbook.Sheets.Count & " - sheets") = vbNo Then Exit Sub
again = True
Exit Sub
err:
MsgBox " you reached the first/only/visible sheet - " & ActiveSheet.name, vbCritical, _
"this w.b contains " & ActiveWorkbook.Sheets.Count & " - sheets"
Loop
End Sub

lior03
08-14-2008, 02:49 AM
please correct my msgbox:

Dim pass As VbMsgBoxResult
On Error Resume Next
pass = MsgBox ("you entered - " & ActiveSheet.name & " - " & ActiveSheet.index &chr(13) _
& Chr(10) & " would like to visit previous press yes: " & ActiveSheet.Previous.name & Chr(13) _
& Chr(10) & " would like to visit next press no " & ActiveSheet.Next.name, vbInformation + vbYesNoCancel, & (chr(13) _
& Chr(10) & "this w.b contains " &ActiveWorkbook.Sheets.Count & " - sheets")
Select Case pass
Case vbYes
ActiveSheet.Previous.Select
Case vbNo
ActiveSheet.Next.Select
Case vbCancel
Exit Sub
Exit Sub
End Select

thanks