Home |
Search |
Today's Posts |
|
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
I have this code in a VBA module:
Rows(1).Insert Range("A1").Value = "H" Range("B1").Value = SheetName Range("C1").Value = Date Range("C1").NumberFormat = "m/dd/yyyy" Range("C1").NumberFormat = "@" When debugging, it returns the correct date, yet when I view the modified worksheet, this date is displayed as a number, then stored as one. How can I ensure that it is saved in m/dd/yyyy format? I've tried this with and without that last NumberFormat statement with the same result. Kevin -- Message posted via http://www.officekb.com |
#2
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
hi Kdub
you have a wrong line try this "Kdub via OfficeKB.com" wrote: Rows(1).Insert Range("A1").Value = "H" Range("B1").Value = SheetName Range("C1").Value = Date Range("C1").NumberFormat = "m/dd/yyyy" I have this code in a VBA module: Rows(1).Insert Range("A1").Value = "H" Range("B1").Value = SheetName Range("C1").Value = Date Range("C1").NumberFormat = "m/dd/yyyy" Range("C1").NumberFormat = "@" When debugging, it returns the correct date, yet when I view the modified worksheet, this date is displayed as a number, then stored as one. How can I ensure that it is saved in m/dd/yyyy format? I've tried this with and without that last NumberFormat statement with the same result. Kevin -- Message posted via http://www.officekb.com |
#3
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Thanks for you help, but that gave me the same result. Here
is what I found that works: Rows(1).Insert Range("A1").Value = "H" Range("B1").Value = SheetName Range("C1").NumberFormat = "@" Range("C1") = Format(Date, ("MM/DD/YYYY")) If I format the cell as text before storing the formatted date, it stores my date in the correct format. Thanks for the help. Kevin -- Message posted via http://www.officekb.com |
#4
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
It may store it to appear as the correct format, but it isn't being stored
as a date value - at least not running your code in xl2003, US English. -- Regards, Tom Ogilvy "Kdub via OfficeKB.com" wrote in message ... Thanks for you help, but that gave me the same result. Here is what I found that works: Rows(1).Insert Range("A1").Value = "H" Range("B1").Value = SheetName Range("C1").NumberFormat = "@" Range("C1") = Format(Date, ("MM/DD/YYYY")) If I format the cell as text before storing the formatted date, it stores my date in the correct format. Thanks for the help. Kevin -- Message posted via http://www.officekb.com |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
saving a file with a date | Excel Worksheet Functions | |||
Saving with name and date macro | Excel Discussion (Misc queries) | |||
save as future date eg expected delivery date | Excel Discussion (Misc queries) | |||
Modify Date Changes when NOT saving | Excel Discussion (Misc queries) | |||
Saving with date in filename | Excel Programming |