PDA

View Full Version : vba for replacing the charater in cell



clif
04-02-2013, 08:26 AM
What is the code to replace charaters in cell



In my range A1 is 2017/8/9


I want to replace the string 2017/8/9 to 2017.8.9 in vba

and then save 2017.8.9 as the file name.

How to do so? Thank you very much!

Kenneth Hobs
04-02-2013, 09:29 AM
Are you sure it is a string and not a date? In A1, press Ctrl+1 to see the format. If a date, you can keep the date and just change the format or actually create a string. I recommend saving it as a date and formatting to suit.

clif
04-02-2013, 09:37 AM
I just want to know the code for replace "/" by "." in a cell .
Thanks

Kenneth Hobs
04-02-2013, 11:27 AM
Worksheets("Sheet1").Range("A1").Value = Replace(Worksheets("Sheet1").Range("A1").Value, "/", ".")