why my date shows up as 12:00:00 AM?

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

The following code works - except when I query the intermediate window for
?begbase, I get "12:00:00 AM" and I don't understand why. Any help would be
much appreciated.


Public reviewbeg As Date
myfilename = InputBox("What will this file be named?")

ActiveWorkbook.SaveAs (myfilename)
Range("a2").Select
Selection.CurrentRegion.Select

Set myrange = Range("a2").CurrentRegion
Set daterange = myrange.Offset(, myrange.Columns.Count).Resize(1, 1)
daterange.Select

reviewbeg = InputBox("What date (MM/DD/YYYY) will mark the beginning of
the review period?")
ActiveCell.FormulaR1C1 = reviewbeg
ActiveCell.NumberFormat = "m/d/yy h:mm;@"

daterange.Name = "begrevdate"
daterange.Offset(2).Name = "begbase"
daterange.Offset(2).FormulaR1C1 =
"=date(YEAR(begrevdate)-1,month(begrevdate),day(begrevdate))"
 
Instead of
reviewbeg = InputBox("What date (MM/DD/YYYY) will mark the beginning of
the review period?")
ActiveCell.FormulaR1C1 = reviewbeg
ActiveCell.NumberFormat = "m/d/yy h:mm;@"

Wouldn't this be easier. BTW. for the current year just use m/d

Sub putdate()'Excel should automatically format as date
ActiveCell = InputBox("Enter Date mm/dd/yyyy")
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