View Single Post
  #4   Report Post  
Posted to microsoft.public.excel.programming
Rick Rothstein Rick Rothstein is offline
external usenet poster
 
Posts: 5,934
Default Remove DateTimestamp from String

Not sure of the OP's naming system, but you could get a false hit with a
name like this...

Mystr = "Change 69231-A Ticket2008-10-01 14.48.18.953.xls"

--
Rick (MVP - Excel)


"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