Home |
Search |
Today's Posts |
#12
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Thanks Rick
Both suggestions are interesting alternatives. -- Gary''s Student - gsnu200827 "Rick Rothstein" wrote: This is basically your routine, but structured around a For Each loop... Function GetDate(ByVal S As String, Which As Long) As Date Words = Split(S) For Each W In Words If IsDate(W) Then X = X + 1 If X = Which Then GetDate = CDate(W) Exit For End If End If Next End Function -- Rick (MVP - Excel) "Rick Rothstein" wrote in message ... Here is a completely different approach (although if I had to guess, I'd say your approach may be slightly efficient)... Function GetDate(ByVal S As String, Which As Long) As Date Words = Split(S) For X = 0 To UBound(Words) If Not IsDate(Words(X)) Then Words(X) = "" Next GetDate = Split(WorksheetFunction.Trim(Join(Words)))(Which - 1) End Function -- Rick (MVP - Excel) "Gary''s Student" wrote in message ... Consider: Function getdate(r As Range, which As Integer) As Date s = Split(r.Value, " ") i = 1 For j = 0 To UBound(s) If IsDate(s(j)) Then If i = which Then getdate = s(j) Exit Function Else i = i + 1 End If End If Next End Function So that if A1 contains: Now is the time 1/24/2009 for all 12/25/1945 men to then =getdate(A1,1) will return 1/24/2009 and =getdate(A1,2) will return 12/25/1945 -- Gary''s Student - gsnu2007k "bpotter" wrote: I have an auto generated workbook that I am pulling reports from. In the very first row I have the following string: ///CST Period Variance Report - Cement (Initial Date: 1/14/2009 Compare Date: 1/13/2009 (Yellow/Change) | Gross Volumes | Operated Wells)\\\ What I would like to do is pull the first date after initial date and find that date on another workbook. I can't even think of how to start. Please help. Bryan |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Finding string and color the found string | Excel Programming | |||
finding a name in a string | Excel Worksheet Functions | |||
Finding A string | Excel Programming | |||
finding what numbers are in a string | Excel Worksheet Functions | |||
Finding a string | Excel Programming |