ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Change MM/DD/YYYY to MM.DD.YYYY (https://www.excelbanter.com/excel-programming/356106-change-mm-dd-yyyy-mm-dd-yyyy.html)

[email protected]

Change MM/DD/YYYY to MM.DD.YYYY
 
Does some kind soul have a macro to change MM/DD/YYYY to MM.DD.YYYY .

Thanks.


Carim

Change MM/DD/YYYY to MM.DD.YYYY
 
Hi,

No need for a macro ...
Just Format Custom
and type your format mm.dd.yyyy

HTH
Carim


[email protected]

Change MM/DD/YYYY to MM.DD.YYYY
 
Thanks Carim ...

I need a VBA solution that works on a String.


Carim

Change MM/DD/YYYY to MM.DD.YYYY
 
If you dealing with normal text, go ahead with
Sub Macro1()
ActiveCell.Replace What:="/", Replacement:=".", LookAt:=xlPart, _
SearchOrder:=xlByRows, MatchCase:=False
Cells.Find(What:="/", After:=ActiveCell, LookIn:=xlFormulas,
LookAt:= _
xlPart, SearchOrder:=xlByRows, SearchDirection:=xlNext,
MatchCase:=False) _
.Activate
End Sub

HTH
Cheers
Carim


Tom Ogilvy

Change MM/DD/YYYY to MM.DD.YYYY
 
Sub ee()
Dim sStr As String, sStr1 As String
sStr = "01/18/2006"
MsgBox sStr
sStr1 = Replace(sStr, "/", ".")
MsgBox sStr1
End Sub

--
Regards,
Tom Ogilvy

" wrote:

Thanks Carim ...

I need a VBA solution that works on a String.



[email protected]

Change MM/DD/YYYY to MM.DD.YYYY
 
The easiest way is to use the Text() Function.. in pure Excel you would
just do

Text("10/12/1984", "mm.dd.yyyy")

So to run it in VB, do this:

Application.Worksheetfunction.Text("10/12/1984", "mm.dd.yyyy")

Easy one liner


[email protected]

Change MM/DD/YYYY to MM.DD.YYYY
 
I went with the easy one liner.

I hadn't seen Application.Worksheetfunction before so that made the
solution especially sweet.

Thanks also to Carim.

You guys make the internet great!



All times are GMT +1. The time now is 10:25 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com