LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default CDate cannot coerce value of IsDate(true)?


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

--
tkstoc
-----------------------------------------------------------------------
tkstock's Profile: http://www.excelforum.com/member.php...fo&userid=1444
View this thread: http://www.excelforum.com/showthread.php?threadid=27419

 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
IsDate? Arne Hegefors Excel Worksheet Functions 3 January 30th 07 01:44 PM
Function to return True/False if all are validated as True by ISNU Tetsuya Oguma Excel Worksheet Functions 2 March 15th 06 10:28 AM
IsDate Function Don Lloyd Excel Programming 14 August 23rd 04 05:57 AM
Getting Excel to not try to coerce numbers to Date R Avery Excel Programming 5 July 20th 04 10:37 PM
What is the differance between cdate and ... Bruccce Excel Programming 3 August 7th 03 09:00 PM


All times are GMT +1. The time now is 10:39 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"