ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Discussion (Misc queries) (https://www.excelbanter.com/excel-discussion-misc-queries/)
-   -   Date Posting (https://www.excelbanter.com/excel-discussion-misc-queries/166522-date-posting.html)

Jim May

Date Posting
 
In a new WB - Book1 - in the immediate window I type in:

x = now
? x
11/18/2007 10:25:29 AM

x =Format(x,"mmmm dd, yyyy")
? x
November 18, 2007

Range("A1") = x
===================================
Why does A1 display 18-Nov-07 (formula bar = 11/18/2007) ??

TIA,

Jim



Dave Peterson

Date Posting
 
If you want to treat that cell like text, you could use:

Range("A1") = "'" & Format(date,"mmmm dd, yyyy")
or
with range("a1")
.numberformat = "@" 'text
.value = Format(Date,"mmmm dd, yyyy")
end with

if you want to treat that cell as a date:
with range("a1")
.numberformat = "mmmm dd, yyyy"
.value = date
end with


Jim May wrote:

In a new WB - Book1 - in the immediate window I type in:

x = now
? x
11/18/2007 10:25:29 AM

x =Format(x,"mmmm dd, yyyy")
? x
November 18, 2007

Range("A1") = x
===================================
Why does A1 display 18-Nov-07 (formula bar = 11/18/2007) ??

TIA,

Jim


--

Dave Peterson


All times are GMT +1. The time now is 10:16 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com