change datestamp from yyyy-mm-dd to yymmdd

  • Thread starter Thread starter jst_se
  • Start date Start date
J

jst_se

I have an auto inserted datestamp when I open a workbook. The dateformt
is yyyy-mm-dd (example: 2004-07-22), and I wonder if there are any way
to convert it to yymmdd (example: 040722)?
Here's the VBA source I use to get the datestamp:

Private Sub Workbook_Open()
If Sheets("dayreport").Range("T5") = "" Then
Sheets("dayreport").Range("T5") = Date
Else
End If
End Sub
 
Hi
try
Private Sub Workbook_Open()
with Sheets("dayreport").Range("T5")
If .value = "" Then
.value = Date
.numberformat="YYMMDD"
End If
end with
End Sub
 
Thank you, Frank! That works just fine :)

Frank said:
Hi
try
Private Sub Workbook_Open()
with Sheets("dayreport").Range("T5")
If .value = "" Then
.value = Date
.numberformat="YYMMDD"
End If
end with
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