View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.misc
Dave O
 
Posts: n/a
Default removing date data from a cell

Assuming the From and Through cells are *always* in the format
From colon space weekday comma space month space daynumber comma space

year
and
Through colon space weekday comma space month space daynumber comma
space year

....then this code will convert the textual dates within those cells
into Excel-readable dates.

Sub test()
Dim From As Date, Thru As Date

From = DateValue(Mid(Range("a1").Value, InStr(1, Range("a1").Value, ",

") + 1, Len(Range("a1").Value)))
Thru = DateValue(Mid(Range("b1").Value, InStr(1, Range("b1").Value, ",
") + 1, Len(Range("b1").Value)))


End Sub

This code works by ignoring the From: , Through: , and weekday name,
and converting the remainder of the string into a date using the
DateValue function in VBA.