T
tkstock
I am using the following code to decompose the date out of a textua
description. However, when it finds the value "1058 8" in the text, i
says that it can be coerced to a date, but then when I use CDate t
coerce it, I get an application error. Any thoughts, anyone? Is thi
a known problem?
Here is my code:
Sub PullOutDate()
For Each x In Selection.Cells
l = Len(x.Value)
For y = 1 To l - 8
If IsDate(Mid(x.Value, y, 6)) Then
x.Cells(1, 2).Value = CDate(Mid(x.Value, y, 6))
ElseIf IsDate(Mid(x.Value, y, 7)) Then
x.Cells(1, 2).Value = CDate(Mid(x.Value, y, 7))
ElseIf IsDate(Mid(x.Value, y, 8)) Then
x.Cells(1, 2).Value = CDate(Mid(x.Value, y, 8))
End If
Next y
Next x
End Sub
Thanks for your help!
Tom Stoc
description. However, when it finds the value "1058 8" in the text, i
says that it can be coerced to a date, but then when I use CDate t
coerce it, I get an application error. Any thoughts, anyone? Is thi
a known problem?
Here is my code:
Sub PullOutDate()
For Each x In Selection.Cells
l = Len(x.Value)
For y = 1 To l - 8
If IsDate(Mid(x.Value, y, 6)) Then
x.Cells(1, 2).Value = CDate(Mid(x.Value, y, 6))
ElseIf IsDate(Mid(x.Value, y, 7)) Then
x.Cells(1, 2).Value = CDate(Mid(x.Value, y, 7))
ElseIf IsDate(Mid(x.Value, y, 8)) Then
x.Cells(1, 2).Value = CDate(Mid(x.Value, y, 8))
End If
Next y
Next x
End Sub
Thanks for your help!
Tom Stoc