Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 114
Default Strange find and replace query

I use the code below to select a column of data and replace . with a /
so I can sort the data in chronological order (as a date). However,
this only works if I manually find and replace (with the find and
replace dialogue). If I use the macro below, the dates are sometimes
adjusted (day and month is switched). Also, when the data is then
sorted, it does not get sorted in chronological order (only when it is
done manually does the data sort correctly).

The original data is an extract from one of our work databases (which
I have no hope of amending).
Not sure if really the workbook needs to be viewed, but not sure how I
can post this to the group?
Any ideas?

Matt

Sub Change_To_Date_Format()

Dim C As Range
Dim EndCell As String

Range("J3").Select


EndCell = ActiveCell.End(xlDown).Address

Range("J3", EndCell).Select

Selection.Replace What:=".", Replacement:="/", LookAt:=xlPart, _
SearchOrder:=xlByRows, MatchCase:=False, SearchFormat:=False,
_
ReplaceFormat:=False


End Sub
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,533
Default Strange find and replace query

Hi Matt

Try to format column J as Date and run the sub afterwards.

Regards,

Per


"MJKelly" skrev i meddelelsen
...
I use the code below to select a column of data and replace . with a /
so I can sort the data in chronological order (as a date). However,
this only works if I manually find and replace (with the find and
replace dialogue). If I use the macro below, the dates are sometimes
adjusted (day and month is switched). Also, when the data is then
sorted, it does not get sorted in chronological order (only when it is
done manually does the data sort correctly).

The original data is an extract from one of our work databases (which
I have no hope of amending).
Not sure if really the workbook needs to be viewed, but not sure how I
can post this to the group?
Any ideas?

Matt

Sub Change_To_Date_Format()

Dim C As Range
Dim EndCell As String

Range("J3").Select


EndCell = ActiveCell.End(xlDown).Address

Range("J3", EndCell).Select

Selection.Replace What:=".", Replacement:="/", LookAt:=xlPart, _
SearchOrder:=xlByRows, MatchCase:=False, SearchFormat:=False,
_
ReplaceFormat:=False


End Sub


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/Replace Event or Find/Replace for Protected Sheet ... Joe HM Excel Programming 2 October 27th 07 03:55 PM
Find/Replace External Data Web Query Gary Spranger Excel Worksheet Functions 3 July 4th 07 06:40 PM
find and replace macro strange behaviour Nicawette Excel Discussion (Misc queries) 3 June 13th 06 08:49 PM
cell.replace strange behaviour Nicawette Excel Programming 5 June 13th 06 08:29 PM
What is this Strange Characet? Find/Replace D[_6_] Excel Programming 12 November 25th 04 06:33 AM


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

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"