+ Reply to Thread
Results 1 to 7 of 7

Extract each substring from current cell

Hybrid View

  1. #1
    Administrator 6StringJazzer's Avatar
    Join Date
    01-27-2010
    Location
    Tysons Corner, VA, USA
    MS-Off Ver
    MS 365 Family 64-bit 2502
    Posts
    26,779

    Re: Extract each substring from current cell

    I had an error, which is corrected in the attached but the formula becomes very unwieldy compared to the ones above.

    I have also added a UDF here if you care to use one, also in the attached.

    ' Extract the nth occurrence of text delimited by ldelim and rdelim, including the
    ' delimiters
    Public Function DelimitedText( _
                      c As Range, _
                      ldelim As String, _
                      rdelim As String, _
                      Optional n As Long = 1) _
                    As String
    
       Dim s As Variant
       Dim stemp As String
       Dim result As Variant
       
       result = InStr(c.Value, ldelim)
       If result = 0 Then
          DelimitedText = "#LDELIM!" ' left delimited not found
       Else
       
          s = Split(c.Value, ldelim)
          stemp = ldelim & s(n)
          result = InStr(stemp, rdelim)
          If result = 0 Then
             DelimitedText = "#RDELIM!" ' right delimiter not found
          Else
             DelimitedText = Mid(stemp, 1, InStr(stemp, rdelim))
          End If
       End If
    
    End Function
    Attached Files Attached Files
    Jeff
    | | |會 |會 |會 |會 | |:| | |會 |會
    Read the rules
    Use code tags to [code]enclose your code![/code]

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1