View Single Post
  #5   Report Post  
Posted to microsoft.public.excel.worksheet.functions
Don Guillett Don Guillett is offline
external usenet poster
 
Posts: 10,124
Default Taking out string part which represents date

OR to get May 2002

Sub getdatefromstring()
For Each c In Selection
x = Mid(c, InStrRev(c, "-") + 1, 4)
md = Format(DateSerial(Right(x, 2), Left(x, 2), 1), "mmm yyyy")
MsgBox md
Next c
End Sub

--
Don Guillett
SalesAid Software

"Don Guillett" wrote in message
...
try

Sub getdatefromstring()
For Each c In range("a2:a22")'Selection
x = Mid(c, InStrRev(c, "-") + 1, 4)
md = Format(DateSerial(2006, Left(x, 2), _
Right(x, 2)), "mm/dd/yyyy")
MsgBox md
Next c
End Sub


--
Don Guillett
SalesAid Software

"c8tz" wrote in message
oups.com...
Hi,

I have a string eg.125-64-0502L where 0502 represents May 2002 - how
can i specify that without doing so manually.

thanks in advance for your assistance,

c8tz~