#1   Report Post  
Jeff
 
Posts: n/a
Default Replace Text w/ VBA

Hello,

I need help to designing a VBA macro that would replace in column K:
the following text "30.11.2004" into text "11/30/2004".
I need this macro to be as generic as possible since I may have other texts
such as 30.09.2004, etc.
Thanks,

  #2   Report Post  
Excel heavy user
 
Posts: n/a
Default

Hi,

You might want to try EditReplace and replace a "." with a "/".

Hope that helps.

Jason

"Jeff" wrote:

Hello,

I need help to designing a VBA macro that would replace in column K:
the following text "30.11.2004" into text "11/30/2004".
I need this macro to be as generic as possible since I may have other texts
such as 30.09.2004, etc.
Thanks,

  #3   Report Post  
Jeff
 
Posts: n/a
Default

Thank you,

I still need to inverse the month and the date. That's Why I need a VBA
Macro.
Regards,


"Excel heavy user" wrote:

Hi,

You might want to try EditReplace and replace a "." with a "/".

Hope that helps.

Jason

"Jeff" wrote:

Hello,

I need help to designing a VBA macro that would replace in column K:
the following text "30.11.2004" into text "11/30/2004".
I need this macro to be as generic as possible since I may have other texts
such as 30.09.2004, etc.
Thanks,

  #4   Report Post  
Dave Peterson
 
Posts: n/a
Default

If you only have to do this once, you could change your windows regional
settings to look like dmy, then do that edit|replace. (then change the regional
settings back to dmy.)

But as a macro:

Option Explicit
Sub testme01()

Dim myCell As Range
Dim myRng As Range

Set myRng = Selection

'30.11.2004
For Each myCell In myRng.Cells
With myCell
.Value = DateSerial(Mid(.Value, 8, 4), _
Mid(.Value, 4, 2), _
Left(.Value, 2))
.NumberFormat = "mm/dd/yyyy"
End With
Next myCell
End Sub

This does assume that the input is all the same dd.mm.yyyy (10 characters).


Jeff wrote:

Thank you,

I still need to inverse the month and the date. That's Why I need a VBA
Macro.
Regards,

"Excel heavy user" wrote:

Hi,

You might want to try EditReplace and replace a "." with a "/".

Hope that helps.

Jason

"Jeff" wrote:

Hello,

I need help to designing a VBA macro that would replace in column K:
the following text "30.11.2004" into text "11/30/2004".
I need this macro to be as generic as possible since I may have other texts
such as 30.09.2004, etc.
Thanks,


--

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
how to find replace text or symbol with carriage return jo New Users to Excel 11 April 4th 23 10:41 AM
Read Text File into Excel Using VBA Willie T Excel Discussion (Misc queries) 13 January 8th 05 12:37 AM
How do I compare two columns on seperate sheets and replace text . hag400 Excel Worksheet Functions 1 December 28th 04 02:32 PM
Macro or Function to make text size to suite text Length? lbbss Excel Discussion (Misc queries) 4 December 14th 04 07:53 PM
How to Replace numbers and text with numbers only? Robert Judge Excel Worksheet Functions 3 November 5th 04 04:36 PM


All times are GMT +1. The time now is 02:45 PM.

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

About Us

"It's about Microsoft Excel"