Welcome to the Excel Forum

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed.

Please Register to Remove these Ads

Please Register to Remove these Ads



Reply
  #1  
Old 06-09-2009, 05:54 AM
Rikuk Rikuk is offline
Registered User
 
Join Date: 23 Aug 2005
Posts: 53
Rikuk is becoming part of the community
Extract Certain Text

Please Register to Remove these Ads

Within my access database I have a field that contains job update information.

Is it possible to extract from this field the date if the field contains the pharse Deferral Online.

Examples of the text Text in Red required extracting

SANDRA ADVISED TO SEND OVER

Job deferred by BNEI01, At 08/Jun/2009 1328, From 08/Jun/2009 1719 To 08/Jun/2009 1719

Job Referred and Authorised by RDAV01, At 08/Jun/2009 1331

Deferral Online on 08/06/2009 at 1549 From 08/06/2009 171900 To 26/06/2009 2359



LOGGED WITH GIDGE AT SUPPLIER ON REFERENCE 581868

Job deferred by MDEA01, At 08/Jun/2009 0915, From 08/Jun/2009 0540 To 09/Jun/2009 0540

Deferral Online on 08/06/2009 at 1048 From 08/06/2009 054000 To 08/06/2009 1700



Rik
Reply With Quote
  #2  
Old 06-09-2009, 08:40 AM
bhill bhill is offline
Registered User
 
Join Date: 20 Mar 2008
Location: Buffalo, NY USA
Posts: 42
bhill is becoming part of the community
Re: Extract Certain Text

You can do it, but you'll need a custom function. I wasn't sure if the samples you provided were in one record (with carriage returns in them) or if they appear on multiple rows. This function will account for either. You can call it within a query like so: Find_Date(someinputdata).

Code:
Public Function Find_Date(stIn As Variant) As String
    Dim stQual As String
    Dim stQual1 As String
    Dim intPos As Integer
    Dim intPos1 As Integer

    stQual = "Deferral Online"
    stQual1 = "To "

    If Len(stIn) = 0 Then 'If there is no input, end the function
        Find_Date = ""
        Exit Function
    End If

    If InStr(1, stIn, stQual) <> 0 Then 'Determine if stQual exists in the input
        intPos = InStr(1, stIn, stQual)    'Position of stQual
        intPos1 = InStr(intPos, stIn, stQual1)    'Position of stQual1 from stQual position
        Find_Date = Mid(stIn, intPos1 + Len(stQual1), 10)    'isolates the date value from stQual1 Position and returns it
    Else 'if stQual doesn't exist in the input, return empty
        Find_Date = ""
    End If

End Function
Reply With Quote


Reply

Bookmarks


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

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

Forum Jump