View Single Post
  #4   Report Post  
Posted to microsoft.public.excel.programming
Mike Fogleman[_2_] Mike Fogleman[_2_] is offline
external usenet poster
 
Posts: 206
Default Remove DateTimestamp from String

For any file extension use:

Mystr = Left(Mystr, InStr(Mystr, "-") - 5) & _
Right(Mystr, Len(Mystr) - InStrRev(Mystr, ".") + 1)

Mike F
"Mike Fogleman" wrote in message
...
This assumes a 4-digit year, a "-" following the year, and removal of all
text to the right of the year.

Sub test()
Dim Mystr As String

Mystr = "Change 69231 Ticket2008-10-01 14.48.18.953.xls"
Mystr = Left(Mystr, InStr(Mystr, "-") - 5) & ".xls"
End Sub

Mike F
"Steve" wrote in message
...
All,
I'm working on a macro that works with the name of files in a certain
directory.

My problem is that some of the files may have a datetimestamp within
the filename.

example: "Change 69231 Ticket2008-10-01 14.48.18.953.xls"

Would like to change to "Change 69231 Ticket.xls"


How can I find and delete the timestamp within a string like the
above.

Steve