Add date to cell with open macro

  • Thread starter DDub207 via OfficeKB.com
  • Start date
D

DDub207 via OfficeKB.com

This should have been easy for me to figure out but I couldn't do it. I'm
just trying to have a cell auto-populate with the current date. I can't use
the =today() function on the sheet because it changes the date on old copies
when they are opened. I would like this to be a workbook_open macro that
works with the one I have below to advance invoice dates. The cell I would
like the date to populate in is M13. Thank, Duane.

Private Sub Workbook_Open()
Range("m3").Value = Range("m3").Value + 1
End Sub
 
Z

Zone

I presume if m13 already has something in it, it's an "old copy", so you
wouldn't want to put the date in if there's already something in m13. This
just adds the date to m13 if it's empty.
HTH, James

Private Sub Workbook_Open()
Range("m3").Value = Range("m3").Value + 1
If Range("m13") = "" Then Range("m13") = Now
End Sub
 
D

DDub207 via OfficeKB.com

Thanks... It works.

Paul said:
give this a try

Range("m3").Value = Date

Paul B
This should have been easy for me to figure out but I couldn't do it. I'm
just trying to have a cell auto-populate with the current date. I can't
[quoted text clipped - 9 lines]
Range("m3").Value = Range("m3").Value + 1
End Sub
 
D

DDub207 via OfficeKB.com

Thanks... It works.

Vergel said:
Duane,

To put the current date in M3:

Range("m3").Value = Date
This should have been easy for me to figure out but I couldn't do it. I'm
just trying to have a cell auto-populate with the current date. I can't use
[quoted text clipped - 6 lines]
Range("m3").Value = Range("m3").Value + 1
End Sub
 
D

DDub207 via OfficeKB.com

Thanks for your help.
I presume if m13 already has something in it, it's an "old copy", so you
wouldn't want to put the date in if there's already something in m13. This
just adds the date to m13 if it's empty.
HTH, James

Private Sub Workbook_Open()
Range("m3").Value = Range("m3").Value + 1
If Range("m13") = "" Then Range("m13") = Now
End Sub
This should have been easy for me to figure out but I couldn't do it. I'm
just trying to have a cell auto-populate with the current date. I can't
[quoted text clipped - 9 lines]
Range("m3").Value = Range("m3").Value + 1
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

Top