+ Reply to Thread
Results 1 to 12 of 12

Help Extracting Specific Text From Inconsistent Text Strings

  1. #1
    Registered User
    Join Date
    01-08-2020
    Location
    INDONESIA
    MS-Off Ver
    2016
    Posts
    36

    Help Extracting Specific Text From Inconsistent Text Strings

    Hello Excel Forum,

    I'm Trying to Extracting Specific Text/Word From Inconsistent Text Strings while The Specific Text/Word have a format 4 letter words following with 5-7 Number. from one data cell the Inconsistent Text Strings it can be 1 or more Specific Text/Word need to extract inside separate column if possible.


    Here the EX from my data set, while showing the result what i want if possible.



    I'm hoping someone here can figure this out. Thank you so much for any help you can offer.
    Attached Files Attached Files

  2. #2
    Forum Expert bebo021999's Avatar
    Join Date
    07-22-2011
    Location
    Vietnam
    MS-Off Ver
    Excel 2016
    Posts
    9,466

    Re: Help Extracting Specific Text From Inconsistent Text Strings

    With Ex2016,I would suggest using VBA code.
    Are you OK with VBA solution?
    Quang PT

  3. #3
    Registered User
    Join Date
    01-08-2020
    Location
    INDONESIA
    MS-Off Ver
    2016
    Posts
    36

    Re: Help Extracting Specific Text From Inconsistent Text Strings

    Hello, thx for the reply.

    I never use VBA, but if that the only solution for now i gladly accept the offer while try to learn how to using VBA Code.

    really appreciate it

  4. #4
    Registered User
    Join Date
    01-08-2020
    Location
    INDONESIA
    MS-Off Ver
    2016
    Posts
    36

    Re: Help Extracting Specific Text From Inconsistent Text Strings

    Quote Originally Posted by bebo021999 View Post
    With Ex2016,I would suggest using VBA code.
    Are you OK with VBA solution?
    Hello sir, i'm okay with VBA solution.

    and really big thanks for your help

  5. #5
    Forum Expert
    Join Date
    05-05-2015
    Location
    UK
    MS-Off Ver
    Microsoft Excel for Microsoft 365 MSO (Version 2402 Build 16.0.17328.20068) 64-bit
    Posts
    28,216

    Re: Help Extracting Specific Text From Inconsistent Text Strings

    Do you have a list of the 4 letter prefixes (MRTU, FCIU etc) ?
    If that takes care of your original question, please select Thread Tools from the menu link above and mark this thread as SOLVED.

  6. #6
    Registered User
    Join Date
    01-08-2020
    Location
    INDONESIA
    MS-Off Ver
    2016
    Posts
    36

    Re: Help Extracting Specific Text From Inconsistent Text Strings

    Quote Originally Posted by JohnTopley View Post
    Do you have a list of the 4 letter prefixes (MRTU, FCIU etc) ?
    Unfortunately No. But let's just say it can be list, the list would be much maybe more than 50 four letter prefixes. I will try to make the list


    for now Here the list i what i know
    MRLU
    MRTU
    SEGU
    TCLU
    TCNU
    TDRU
    TGHU
    CMAU
    FCIU
    GESU
    SCZU
    SMAU
    CRSU
    DFSU
    OOLU
    OOCU
    MAGU
    EGHU

  7. #7
    Forum Expert
    Join Date
    05-05-2015
    Location
    UK
    MS-Off Ver
    Microsoft Excel for Microsoft 365 MSO (Version 2402 Build 16.0.17328.20068) 64-bit
    Posts
    28,216

    Re: Help Extracting Specific Text From Inconsistent Text Strings

    Thank you for the list and it cerainly would be of further help if you can add to it.

    It may be possible to find a solution without the list but that certainly depends on how representative your sample file is.

  8. #8
    Forum Expert bebo021999's Avatar
    Join Date
    07-22-2011
    Location
    Vietnam
    MS-Off Ver
    Excel 2016
    Posts
    9,466

    Re: Help Extracting Specific Text From Inconsistent Text Strings

    Try to search for "ABCD0000000" with first 4 letters followed by 7 (or down to 5) digits
    Try below code
    Click on the arrow object, to refresh the result.

    PHP Code: 
    Option Explicit
    Sub test
    ()
    Dim i&, j&, k&, m&, n&, pos&, x&, t&, num
    Dim sp
    rngst$, arr(), res(1 To 100001 To 4)
    rng Range("A3").CurrentRegion.Value
    ReDim arr
    (1 To UBound(rng) - 11 To 100)
    For 
    2 To UBound(rng)
        
    pos InStr(1rng(i3), "LIFT ON EMPTY")
        
    st Left(rng(i3), IIf(pos 1pos 1Len(rng(i3)))) & "00"
        
    0
        
    For 1 To Len(st) - 11
            
    If isTxt(Mid(stj4)) Then
                m 
    4
                
    For 7 To 5 Step -1
                    num 
    Mid(stmn)
                    If 
    IsNumeric(num) And num 9999 Then
                        k 
    1arr(1k) = "|" n
                        
    Exit For
                    
    End If
                
    Next
            End 
    If
        
    Next
        
    If 0 Then
            
    For 1 To k
                t 
    1res(t1) = rng(i1): res(t2) = rng(i2): res(t3) = rng(i3)
                
    sp Split(arr(1x), "|")
                
    res(t4) = Mid(stsp(0), sp(1))
            
    Next
        End 
    If
    Next
    Range
    ("F3:Z10000").ClearContents
    Range
    ("F3").Resize(t4).Value res
    End Sub
    Function isTxt(st As String) As Boolean
    Dim i
    &
        For 
    1 To 4
            
    If InStr("ABCDEFGHIJKLMNOPQRSTUVWXYZ"Mid(sti1)) = 0 Then
                isTxt 
    False
                
    Exit Function
            
    End If
        
    Next
        isTxt 
    True
    End 
    Function 
    Attached Files Attached Files

  9. #9
    Registered User
    Join Date
    01-08-2020
    Location
    INDONESIA
    MS-Off Ver
    2016
    Posts
    36

    Re: Help Extracting Specific Text From Inconsistent Text Strings

    Quote Originally Posted by bebo021999 View Post
    Try to search for "ABCD0000000" with first 4 letters followed by 7 (or down to 5) digits
    Try below code
    Click on the arrow object, to refresh the result.

    PHP Code: 
    Option Explicit
    Sub test
    ()
    Dim i&, j&, k&, m&, n&, pos&, x&, t&, num
    Dim sp
    rngst$, arr(), res(1 To 100001 To 4)
    rng Range("A3").CurrentRegion.Value
    ReDim arr
    (1 To UBound(rng) - 11 To 100)
    For 
    2 To UBound(rng)
        
    pos InStr(1rng(i3), "LIFT ON EMPTY")
        
    st Left(rng(i3), IIf(pos 1pos 1Len(rng(i3)))) & "00"
        
    0
        
    For 1 To Len(st) - 11
            
    If isTxt(Mid(stj4)) Then
                m 
    4
                
    For 7 To 5 Step -1
                    num 
    Mid(stmn)
                    If 
    IsNumeric(num) And num 9999 Then
                        k 
    1arr(1k) = "|" n
                        
    Exit For
                    
    End If
                
    Next
            End 
    If
        
    Next
        
    If 0 Then
            
    For 1 To k
                t 
    1res(t1) = rng(i1): res(t2) = rng(i2): res(t3) = rng(i3)
                
    sp Split(arr(1x), "|")
                
    res(t4) = Mid(stsp(0), sp(1))
            
    Next
        End 
    If
    Next
    Range
    ("F3:Z10000").ClearContents
    Range
    ("F3").Resize(t4).Value res
    End Sub
    Function isTxt(st As String) As Boolean
    Dim i
    &
        For 
    1 To 4
            
    If InStr("ABCDEFGHIJKLMNOPQRSTUVWXYZ"Mid(sti1)) = 0 Then
                isTxt 
    False
                
    Exit Function
            
    End If
        
    Next
        isTxt 
    True
    End 
    Function 
    Hello Sir,
    Thx for your help, the code is really awesome

    But sorry to trouble you again,
    i have a question about this "When the description Showing more than One Activity, The container name will be break down or extract by it Activity"

    is that possible to do ?

    here the ex : for my question in new data set

    again and again, i'm very grateful for your help
    Attached Files Attached Files

  10. #10
    Forum Expert bebo021999's Avatar
    Join Date
    07-22-2011
    Location
    Vietnam
    MS-Off Ver
    Excel 2016
    Posts
    9,466

    Re: Help Extracting Specific Text From Inconsistent Text Strings

    OK, try again

    PHP Code: 
    Option Explicit
    Sub test
    ()
    Dim i&, j&, k&, m&, n&, pos&, x&, t&, num
    Dim sp
    rngst$, arr(), res(1 To 100001 To 4)
    Dim dic As ObjectSet dic CreateObject("Scripting.Dictionary")
    rng Range("A3").CurrentRegion.Value
    ReDim arr
    (1 To UBound(rng) - 11 To 100)
    For 
    2 To UBound(rng)
        
    pos InStr(1rng(i3), "LIFT ON EMPTY")
        If 
    Not dic.exists(rng(i1)) Then
            
    If pos 0 Then
                st 
    rng(i3) & "00"
            
    Else
                
    st Left(rng(i3), IIf(pos 1pos 1Len(rng(i3)))) & "00"
            
    End If
            
    dic.Add rng(i1), st
        
    Else
            
    st Mid(rng(i3), IIf(pos 1pos 131), 255) & "00"
            
    dic(rng(i1)) = st
        End 
    If
        
    0
        
    For 1 To Len(st) - 11
            
    If isTxt(Mid(stj4)) Then
                m 
    4
                
    For 7 To 5 Step -1
                    num 
    Mid(stmn)
                    If 
    IsNumeric(num) And num 9999 Then
                        k 
    1arr(1k) = "|" n
                        
    Exit For
                    
    End If
                
    Next
            End 
    If
        
    Next
        
    If 0 Then
            
    For 1 To k
                t 
    1res(t1) = rng(i1): res(t2) = rng(i2): res(t3) = rng(i3)
                
    sp Split(arr(1x), "|")
                
    res(t4) = Mid(stsp(0), sp(1))
            
    Next
        End 
    If
    Next
    Range
    ("F3:Z10000").ClearContents
    Range
    ("F3").Resize(t4).Value res
    End Sub
    Function isTxt(st As String) As Boolean
    Dim i
    &
        For 
    1 To 4
            
    If InStr("ABCDEFGHIJKLMNOPQRSTUVWXYZ"Mid(sti1)) = 0 Then
                isTxt 
    False
                
    Exit Function
            
    End If
        
    Next
        isTxt 
    True
    End 
    Function 
    Attached Files Attached Files
    Last edited by bebo021999; 04-22-2024 at 09:45 PM.

  11. #11
    Registered User
    Join Date
    01-08-2020
    Location
    INDONESIA
    MS-Off Ver
    2016
    Posts
    36

    Re: Help Extracting Specific Text From Inconsistent Text Strings

    sorry, It's my bad.

    i give you a not clear example of data set.

    what i want is, the description can be more than one activity and not limited to specific activity such as "lift on empty". it will break down or extract the container number from each activity.

    example (Invoice description have 3 activity) : activity 1 following with 3 cont name, activity 2 following with 2 cont, activity 3 following with 3 cont
    the result see my new excel data

    this is my new example of excel data

    I'm really sorry to trouble you and thanks you for be patient.
    Attached Files Attached Files

  12. #12
    Forum Guru
    Join Date
    08-28-2014
    Location
    USA
    MS-Off Ver
    Excel 2019
    Posts
    17,578

    Re: Help Extracting Specific Text From Inconsistent Text Strings

    Here is a formula-based proposal:
    1. Add a column (E) to the source data populated using: =SUM(E2,D3)
    2. Populate the output columns for Invoice, Code Item and Description using: =IFERROR(INDEX(A$3:A$5,AGGREGATE(15,6,(ROW(A$3:A$5)-ROW(A$2))/(ROWS(G$3:G3)<=$E$3:$E$5),1)),"")
    3. Populate the draft column of container name using: =IF(G3="","",MID(I3,SEARCH("/",SUBSTITUTE(I3,"U","/",COUNTIFS(G$3:G3,G3)))-3,11))
    4. Populate the final column of container name using: =IF(RIGHT(K3,1)="M",LEFT(K3,10),K3)
    Let us know if you have any questions.
    Attached Files Attached Files
    Consider taking the time to add to the reputation of everybody that has taken the time to respond to your query.

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. Help Extracting Text From Inconsistent Text Strings.
    By JN831 in forum Excel Formulas & Functions
    Replies: 51
    Last Post: 03-14-2024, 06:59 AM
  2. [SOLVED] Extract specific strings that is next to a specific text - inconsistent data format
    By pbjgun in forum Excel Formulas & Functions
    Replies: 6
    Last Post: 09-08-2022, 06:29 AM
  3. [SOLVED] Extracting Multiple types of Text Characters from Text Strings
    By DannyGIS in forum Excel General
    Replies: 9
    Last Post: 12-14-2016, 09:35 PM
  4. [SOLVED] Extracting specific data from large inconsistent strings
    By Karnik in forum Excel Formulas & Functions
    Replies: 5
    Last Post: 09-01-2013, 01:52 AM
  5. Extracting numbers and text from inconsistent text/number formatted string
    By Brandivil in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 01-25-2013, 01:46 PM
  6. Extracting numbers from inconsistent text strings
    By netguru in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 09-25-2012, 03:20 AM
  7. Parsing inconsistent text strings into columns in an organized manner
    By jagman1990 in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 12-17-2010, 03:48 PM

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