I need to create macros for current date and yesterday's date

S

Sharyn K

in the format of mm/dd/yy. I don't have much programming experience, is
there an easy way to go about this? I created a macro for inserting today's
date using insert date, but it comes out 11/6/04 instead of 11/06/04 which is
the required format for my documents.

Thanks for any help.

Sharyn
 
S

Steve Yandl

Try something like this.

Sub DatesEnter()
Dim strToday As String
Dim strYesterday As String
strToday = "Today is " & Format$(Now, "mm/dd/yy")
strYesterday = "Yesterday was " & Format$(Now - 1, "mm/dd/yy")
Selection.InsertAfter strToday & vbCrLf & strYesterday
End Sub


Steve
 

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

Top