Akashwani
Well-known Member
- Joined
- Mar 14, 2009
- Messages
- 2,911
Hi,
I keep trying and searching BUT,
I have the following problem..
I want the user to click YES to enter the workbook.
If they click NO, I want the workbook to close.
This is what I have so far...
Dim t As Date
Private Sub Workbook_Open()
Dim s As String
ans = MsgBox("Do you want to Enter?", vbYesNo, "My Workbook?")
If ans = vbYes Then
End If
How do I get the workbook to close if they click NO?
s = InputBox("To Login In Enter your first name")
t = Now
Const strRightAnswer As String = "Ottawa"
Dim strAnswer As String
While Not (strRightAnswer = strAnswer)
strAnswer = InputBox("What is the capital of Canada?")
If Not (LCase(strRightAnswer) = LCase(strAnswer)) Then MsgBox "Incorrect answer please try again."
Wend
End Sub
Private Sub Workbook_BeforeClose(Cancel As Boolean)
MsgBox "You have been active for " & Format(Now - t, "nn") & " minutes and " & Format(Now - t, "ss") & " seconds."
Dim res
res = MsgBox(" Have you finished?", vbYesNo)
If res <> vbYes Then Cancel = True
End Sub
Thanks for you time.
Ak
I keep trying and searching BUT,
I have the following problem..
I want the user to click YES to enter the workbook.
If they click NO, I want the workbook to close.
This is what I have so far...
Dim t As Date
Private Sub Workbook_Open()
Dim s As String
ans = MsgBox("Do you want to Enter?", vbYesNo, "My Workbook?")
If ans = vbYes Then
End If
How do I get the workbook to close if they click NO?
s = InputBox("To Login In Enter your first name")
t = Now
Const strRightAnswer As String = "Ottawa"
Dim strAnswer As String
While Not (strRightAnswer = strAnswer)
strAnswer = InputBox("What is the capital of Canada?")
If Not (LCase(strRightAnswer) = LCase(strAnswer)) Then MsgBox "Incorrect answer please try again."
Wend
End Sub
Private Sub Workbook_BeforeClose(Cancel As Boolean)
MsgBox "You have been active for " & Format(Now - t, "nn") & " minutes and " & Format(Now - t, "ss") & " seconds."
Dim res
res = MsgBox(" Have you finished?", vbYesNo)
If res <> vbYes Then Cancel = True
End Sub
Thanks for you time.
Ak