Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 220
Default Macro to format dates

I'm trying to create a macro that will format some dates on my
spreadsheet...

Column 13 (M) has dates formatted as: Jan 23 2007 12:00AM
- this is always the same length, so Jan 3 would be Jan 3 2007
12:00AM

Column 19 (S) has dates formatted as: 2070109 (which is 1/9/07)

Can someone please help me write a macro to format them as mm/dd/yy,
w/o the time?

I hate to post w/o providing some code but I don't really know where to
start.

Thank You,
Dan

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 220
Default Macro to format dates

Don I tried your code and the result for 2070109 was 10/06/7567 and it
didn't make any changes to Jan 23 2007 12:00AM. I also tried your
suggestion Jim but since Excel doesnt recognize the current formatting
I dont think it can make any changes to it. But thanks for the
suggestions guys, I guess I can probably just use a mid formula or
something to do it.

Thanks
-- Dan

On Jan 24, 12:32 pm, "Don Guillett" wrote:
Sub formatcolumns()
Range("m1,s1").EntireColumn.NumberFormat = "mm/dd/yyyy"

End Sub

--
Don Guillett
SalesAid Software
"Dan R." wrote in ooglegroups.com...



I'm trying to create a macro that will format some dates on my
spreadsheet...


Column 13 (M) has dates formatted as: Jan 23 2007 12:00AM
- this is always the same length, so Jan 3 would be Jan 3 2007
12:00AM


Column 19 (S) has dates formatted as: 2070109 (which is 1/9/07)


Can someone please help me write a macro to format them as mm/dd/yy,
w/o the time?


I hate to post w/o providing some code but I don't really know where to
start.


Thank You,
Dan- Hide quoted text -- Show quoted text -


  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 6,582
Default Macro to format dates

Excel doesn't recognize 2070109 as a date, it thinks you mean the 2070109th
day since 1/1/1900. You would have to use something like text to columns
(data menu), use Fixed Width to split it into 2 and 070109, not import the
column with just 2, and under Column Data Format, choose Date with the YMD
option. Now Excel knows it's a date.

The "Jan 23 2007 12:00AM" might have come in as text. Format the cell to
have General horizontal alignment: if it's left-aligned, it's text, not a
numerical date. Never mind, I just checked, and Excel doesn't recognize it
as a date. It needs a comma after the day and a space before "AM", like
this: "Jan 23, 2007 12:00 AM". You'll have to find/replace "AM" and "PM"
with " AM" and " PM", and " 200" with ", 200", and then Excel will know what
you're up to.

- Jon
-------
Jon Peltier, Microsoft Excel MVP
Tutorials and Custom Solutions
http://PeltierTech.com
_______


"Dan R." wrote in message
ups.com...
Don I tried your code and the result for 2070109 was 10/06/7567 and it
didn't make any changes to Jan 23 2007 12:00AM. I also tried your
suggestion Jim but since Excel doesnt recognize the current formatting
I dont think it can make any changes to it. But thanks for the
suggestions guys, I guess I can probably just use a mid formula or
something to do it.

Thanks
-- Dan

On Jan 24, 12:32 pm, "Don Guillett" wrote:
Sub formatcolumns()
Range("m1,s1").EntireColumn.NumberFormat = "mm/dd/yyyy"

End Sub

--
Don Guillett
SalesAid Software
"Dan R." wrote in
ooglegroups.com...



I'm trying to create a macro that will format some dates on my
spreadsheet...


Column 13 (M) has dates formatted as: Jan 23 2007 12:00AM
- this is always the same length, so Jan 3 would be Jan 3 2007
12:00AM


Column 19 (S) has dates formatted as: 2070109 (which is 1/9/07)


Can someone please help me write a macro to format them as mm/dd/yy,
w/o the time?


I hate to post w/o providing some code but I don't really know where to
start.


Thank You,
Dan- Hide quoted text -- Show quoted text -




Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Dates format Hardeep Kanwar Excel Worksheet Functions 2 September 16th 09 05:44 AM
CONVERT DATES FROM EUROPEAN FORMAT TO US FORMAT les8 New Users to Excel 8 August 8th 06 05:48 PM
Format text 'dates' to real dates Jacy Excel Worksheet Functions 4 July 24th 06 02:10 AM
the dates on cell format make different dates. date formats morph the dates/chang case New Users to Excel 6 April 18th 05 02:41 AM
Macro changes the format of dates Rodolfo Silva Excel Programming 4 August 29th 03 05:12 AM


All times are GMT +1. The time now is 09:37 PM.

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

About Us

"It's about Microsoft Excel"