A Microsoft Excel forum. ExcelBanter

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

Go Back   Home » ExcelBanter forum » Excel Newsgroups » Excel Programming
Site Map Home Register Authors List Search Today's Posts Mark Forums Read Web Partners

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



 
 
Thread Tools Display Modes
  #1  
Old November 30th 04, 02:55 PM posted to microsoft.public.excel.programming
Papa Jonah
external usenet poster
 
Posts: 148
Default why my date shows up as 12:00:00 AM?

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))"

Ads
  #2  
Old November 30th 04, 03:16 PM posted to microsoft.public.excel.programming
Don Guillett[_4_]
external usenet poster
 
Posts: 2,337
Default why my date shows up as 12:00:00 AM?

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

--
Don Guillett
SalesAid Software

"Papa Jonah" > wrote in message
...
> 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))"
>



  #3  
Old November 30th 04, 03:38 PM posted to microsoft.public.excel.programming
Tom Ogilvy
external usenet poster
 
Posts: 27,285
Default why my date shows up as 12:00:00 AM?

I ran your code answering 12/15/2003 then did:

? Range("begbase").Value
12/15/2002


--
Regards,
Tom Ogilvy

"Papa Jonah" > wrote in message
...
> 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))"
>



 




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Date shows as a number Bob[_16_] Excel Discussion (Misc queries) 1 June 7th 11 09:03 PM
blank date shows up as s 1/0/00 Mary Excel Worksheet Functions 2 July 17th 08 12:00 AM
Excel: I enter date and format for date, but shows as number spohar Excel Discussion (Misc queries) 2 March 10th 06 08:40 PM
Date shows as 01/01/00 Kmagg Excel Discussion (Misc queries) 2 September 23rd 05 11:51 PM
date shows 1/1/1900 CycloneGD Excel Worksheet Functions 2 August 24th 05 03:45 PM


All times are GMT +1. The time now is 11:42 PM.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.
Copyright 2004-2014 ExcelBanter.
The comments are property of their posters.