-
IF Formula Using Label
Hi, everyone -
I'm not real sure this is possible, but I figured you guys would know.
I am currently using the code below using two (2) labels within my splash screen to show the current date and time. What I'm wondering is whether there is a way to construct an IF formula using Label1 in the formula. For example, ...... IF Label1< 10/1/2004, play a specific wav file; IF Label1> 10/1/2004, "". In which code string would I include the method?
Code:
Private Sub UserForm_Initialize()
Label1.Caption = Format(Now, "mmmm dd, yyyy")
Label2.Caption = Format(Now, "h:mm:ss AM/PM")
End Sub
Private Sub UserForm_Activate()
Application.OnTime Now + TimeValue("00:00:06"), "KillTheForm"
End Sub
Thanks for the help,
Golf
-
You can do something like:
Code:
Date2 = DateSerial(2004, 10, 1)
If Date > Date2 Then
MsgBox "Play A Sound"
End If
Date2 is the date you set. Date is todays date (The same as Now, but without the time).
No need to even mess with the label caption, just set the caption to the date, and use the date in further calculations as needed.
-
Hi, Golf. Check my signature for how to post your VBA code. :)
-
Hi, Jacob and Dreamboat -
Thanks for the help. I've kind of tinkered with your code, Jake, and seems to work great now.
Code:
Private Sub UserForm_Activate()
Date2 = DateSerial(2004, 10, 1)
If Date < Date2 Then
Sheets("data_entry_sheet").Unprotect ("led52not")
Application.ScreenUpdating = True
DoEvents
ActiveSheet.Shapes("object 258.wav").Select 'warning error msg'
Selection.Verb Verb:=xlPrimary
Sheets("data_entry_sheet").Protect ("led52not")
End If
Application.OnTime Now + TimeValue("00:00:10"), "KillTheForm"
End Sub
Thanks again for the help,
Frank
-