Using date as trigger for macro

M

Mike Milmoe

I want to write a macro, that will look for today's date in a database, and
if it finds it, do another action. I have already designed the other action.

Thanks!

Mike
 
B

BigPig

Hi Mike,

I'm no expert at macros, but you could try:

Worksheets(1).Range("a1") = ""
'dont forget to format cell a1 as the date that the other cell in your
database is.
Worksheets(1).Range("a1") = "=NOW()"

'where "worksheets(?).range("??").text" is the date somewhere in your
database. 'I used b1
If Worksheets(1).Range("a1").Text = Worksheets(1).Range("b1").Text Then
'if same do something
Worksheets(1).Range("c1").Value = "yep they're the same"
Else
'if not do something else
Worksheets(1).Range("c1").Value = "nope they're not"

End If


hth

BigPig
 
G

Gary''s Student

Sub milmoe()
Set r = Range("A1:A100")
For Each rr In r
If rr.Value = DateValue(Now()) Then
MsgBox ("call your macro here")
End If
Next
End Sub
 
M

Mike Milmoe

This worked great. Thanks alot

Mike

Gary''s Student said:
Sub milmoe()
Set r = Range("A1:A100")
For Each rr In r
If rr.Value = DateValue(Now()) Then
MsgBox ("call your macro here")
End If
Next
End Sub
 
Top