VBA Code to add date

  • Thread starter Thread starter npereira
  • Start date Start date
N

npereira

Excellent !

That worked like a charm. Thansk again!

I have another question, but this has no revelance to this topic so
will start a new topic
 
One note of caution using that on a template. Every time you open an invoice
made from that template the date will update to today's date and overwrite
the actual date the Invoice was created. I found this out the hard way
myself.
Mike F
 
Good point.

If that's a concern to the OP:

Option Explicit
Private Sub Workbook_BeforeSave(ByVal SaveAsUI As Boolean, Cancel As Boolean)
With Me.Worksheets("sheet1").Range("e11")
if .value = "" then
.Value = Date
.NumberFormat = "mmmm dd, yyyy"
end if
End With
End Sub

Checks what's in that cell first.
 

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