Retouch code to set alarm via Userform/Inputbox

Oprichnick

Board Regular
Joined
May 30, 2013
Messages
69
Hello, with some book help, I wrote this code:
Code:
Sub Data()
Dim dtime As Date
Dim Ans As Integer
    Ans = MsgBox("Have you transfered the data today?", vbYesNoCancel)
        If Ans = vbYes Then
            MsgBox ("Ok, Keep Your Work")
        ElseIf Ans = vbCancel Then
            Exit Sub
        Else
            MsgBox ("Please transfer data")
End If
End Sub
Sub DataReminder()
Dim dta As String
dta = MsgBox("Do you want to turn the data transfer alarm on?", vbYesNo)
    Select Case Lch
        Case vbYes
            GoTo DataTransfer
        Case vbNo
            Exit Sub
    End Select
        
DataTransfer:
Application.OnTime TimeSerial(1, 3, 0), "Data"
End Sub
Sub Workbook_BeforeClose(Cancel As Boolean)
    dtime As Date
    Application.OnTime dtime, "Data", False
End Sub
However, now I want to set the alarm using an InputBox or preferably a Userform... But I'm clueless... Stay Good
 

Excel Facts

Lock one reference in a formula
Need 1 part of a formula to always point to the same range? use $ signs: $V$2:$Z$99 will always point to V2:Z99, even after copying
Code:
dta = MsgBox("Do you want to turn the data transfer alarm on?", vbYesNo)
    Select Case Lch
That snippet won't work, anyhow. You will probably not even get an error message to tell you it is a mismatch. "Lch" is not defined anywhere that I can see. I think it should be 'dta'.
I question why you would even bother with a message box, input box or UserForm. Just put a button on the sheet with a caption, "Set Alarm" and attach this modified version to it;
Code:
Sub DataReminder()
Application.OnTime TimeSerial(1, 3, 0), "Data"
End Sub
If somebody wants to set the alarm, they just click the button.
 
Upvote 0
Uhm... Yes "Lch" is supposed to be "dta". I know I may do it as you said, however I just want to know how can I do it as I asked...
 
Upvote 0

Forum statistics

Threads
1,223,228
Messages
6,170,871
Members
452,363
Latest member
merico17

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top