Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 26
Default replace . to / in dates

I would like to change . to / of date fields in column M. If I try to find
and replace individually all works Ok but if I use replace all it seem to
change the date. For example when I use replace all for 08.03.2008 it ends up
as 03/08/2008 but 18.03.2008 changes OK to 18/03/2008. Anyone know what I can
do to stop day and month being switched when replace all is used?

Thank you
Prema
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,298
Default replace . to / in dates

try setting the column's format to TEXT before you run the change

"Prema" wrote:

I would like to change . to / of date fields in column M. If I try to find
and replace individually all works Ok but if I use replace all it seem to
change the date. For example when I use replace all for 08.03.2008 it ends up
as 03/08/2008 but 18.03.2008 changes OK to 18/03/2008. Anyone know what I can
do to stop day and month being switched when replace all is used?

Thank you
Prema

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 9,101
Default replace . to / in dates

this code should always work

newdate = DateSerial(Mid(olddate, 7, 4), Mid(olddate, 4, 2), Left(olddate, 2))

"Patrick Molloy" wrote:

try setting the column's format to TEXT before you run the change

"Prema" wrote:

I would like to change . to / of date fields in column M. If I try to find
and replace individually all works Ok but if I use replace all it seem to
change the date. For example when I use replace all for 08.03.2008 it ends up
as 03/08/2008 but 18.03.2008 changes OK to 18/03/2008. Anyone know what I can
do to stop day and month being switched when replace all is used?

Thank you
Prema

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35,218
Default replace . to / in dates

It'll depend on what your windows regional settings for the short date is.

If you have mdy as your short date, then 08.03.2008 will be changed to August 3,
2008.

If you have dmy as your short date, then 08.03.2008 will be changed to March 8,
2008.

So you may find that some of the values actually converted to a date--but not
the date that you wanted.

If your dates are in a single column, you can use:
Select the column
data|text to columns
choose delimited by nothing
and make sure you choose the correct order for the date to match the data.

If you have multiple columns of dates, you can do it multiple times.

Alternatively, you could change your windows regional settings (under control
panel) short date to the order that you need. Then do the edit|replace. And
change that setting back.

I find that formatting my dates in an unambiguous format, like: mmmm dd, yyyy
makes it much easier to check my work.

Prema wrote:

I would like to change . to / of date fields in column M. If I try to find
and replace individually all works Ok but if I use replace all it seem to
change the date. For example when I use replace all for 08.03.2008 it ends up
as 03/08/2008 but 18.03.2008 changes OK to 18/03/2008. Anyone know what I can
do to stop day and month being switched when replace all is used?

Thank you
Prema


--

Dave Peterson
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
Find and Replace Dates in VBA Ladymuck Excel Programming 15 November 6th 07 10:24 AM
How to replace a date, change May to June keeping numerical dates dolphinks72002 Excel Discussion (Misc queries) 2 April 27th 06 01:10 AM
find and replace - replace data in rows to separated by commas msdker Excel Worksheet Functions 1 April 15th 06 01:00 AM
How do I replace dates earlier than certain date? Jose Martinez Excel Discussion (Misc queries) 4 April 29th 05 09:50 PM
VBA Replace Dates Matt Connor Excel Programming 2 February 12th 04 12:34 PM


All times are GMT +1. The time now is 05:09 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"