First of the year

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I have a macro that runs by a command buttom. I want it to check each time
to see if it's after the first of the year, then display a warning message
and not display the messag again until it detects a new year

oldjay
 
Hi OldJay,

Try:

'=============>>
Private Sub CommandButton1_Click()
On Error Resume Next
If Evaluate("DateTrigger") < Year(Date) Then
On Error GoTo 0

MsgBox "Year Change!"
Names.Add Name:="DateTrigger", _
RefersTo:=Year(Date)
End If

'your Code e.g.:
MsgBox "Hi"

End Sub
'<<=============
 
Thanks

Norman Jones said:
Hi OldJay,

Try:

'=============>>
Private Sub CommandButton1_Click()
On Error Resume Next
If Evaluate("DateTrigger") < Year(Date) Then
On Error GoTo 0

MsgBox "Year Change!"
Names.Add Name:="DateTrigger", _
RefersTo:=Year(Date)
End If

'your Code e.g.:
MsgBox "Hi"

End Sub
'<<=============
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top