An Excel UDF that I use.   Add it to your library of UDFs and treat it 
like any other function in Excel.  Insert a "wrapped" EDI file in one 
column, then use this function elsewhere to extract individual elements 
wherever you need them.

e.g.        =EDIGetElement( {source cell}, {element # you want to 
extract}, {delimiter if not '*'}, {terminator if not '~'})



Not sure if anyone will want to use this, but _I_ do and I thought I'd 
share.


Harold DeWayne, CECP, RECS


------------------------------------------------------------------------
Function EDIGetElement(text As Variant, N As Integer, Optional Delimiter 
As String, Optional Terminator As String) As String
' Written by Harold DeWayne, CECP, RECS

If Delimiter = "" Then Delimiter = "*"
If Terminator = "" Then Terminator = "~"

'Returns the nth element from a delimited text string
     Dim txt, str As String
     Dim Count, i As Integer

'Manipulate a copy of the text string
     txt = text

'If a space is used as the delimiter, remove extra spaces
     If Delimiter = Chr(32) Then txt = Application.Trim(txt)

'Check for terminator
     If (Right(txt, 1) = Terminator) Then
         txt = Left(txt, Len(txt) - 1)
     End If

'Add a delimiter to the end of the string
     If (Right(txt, 1) <> Delimiter) Then
         txt = txt & Delimiter
     End If

'Initialize count and element
     Count = 0
     str = ""

'Get each element
     For i = 1 To Len(txt)
         If Mid(txt, i, 1) = Delimiter Then
             Count = Count + 1
             If Count - 1 = N Then
                 EDIGetElement = str
                 Exit Function
             Else
                 str = ""
             End If
         Else
             str = str & Mid(txt, i, 1)
         End If
     Next i
     EDIGetElement = ""
End Function
------------------------------------------------------------------------


[Non-text portions of this message have been removed]



------------------------------------

...
Please use the following Message Identifiers as your subject prefix: <SALES>, 
<JOBS>, <LIST>, <TECH>, <MISC>, <EVENT>, <OFF-TOPIC>

Job postings are welcome, but for job postings or requests for work: <JOBS> IS 
REQUIRED in the subject line as a prefix.Yahoo! Groups Links

<*> To visit your group on the web, go to:
    http://groups.yahoo.com/group/EDI-L/

<*> Your email settings:
    Individual Email | Traditional

<*> To change settings online go to:
    http://groups.yahoo.com/group/EDI-L/join
    (Yahoo! ID required)

<*> To change settings via email:
    [email protected] 
    [email protected]

<*> To unsubscribe from this group, send an email to:
    [email protected]

<*> Your use of Yahoo! Groups is subject to:
    http://docs.yahoo.com/info/terms/

Reply via email to