Remove Values from Delimited String

GonzoB

New Member
Joined
Dec 4, 2021
Messages
43
Hi Helpers,

I have 2 hundred thousand records in a spreadsheet, one of the columns hold semicolon separated values. The number of values stored in this delimited string range from zero to a hundred.

What I would need to do is to remove a big number of values from this semicolon separated list, in a way that the format of the string does not change. The format is that the string 1) starts with ; 2) ends with ; 3) all distinct values are separeted by ;

The below simplified example illustrates how my records look like, what the format of the string is and how the values I need to remove look like.

Book15
ABCDEF
1column Acolumn Bvalues to remove
2Griezmann;a;b;c;d;e;f;g;a
3Müller;a;b;e;f;j;l;d
4Salas;a;d;f;g;h;g
Sheet1



Can you advise what would be the simplest and fastest way to removes the values from the semicolon separates strings?

Thanks in Advance
 
Last edited by a moderator:

Excel Facts

Why are there 1,048,576 rows in Excel?
The Excel team increased the size of the grid in 2007. There are 2^20 rows and 2^14 columns for a total of 17 billion cells.
Assuming at least a single value remains based on your rules. If not, then this would output a single semi-colon.

Book1
ABCDEF
1Column B
2;a;b;c;d;e;f;g;;b;c;e;f;a
3;a;b;e;f;j;l;;b;e;f;j;l;d
4;a;d;f;g;h;;f;h;g
Sheet2
Cell Formulas
RangeFormula
C2:C4C2=MAP(B2:B4,LAMBDA(x,LET(y,TEXTSPLIT(x,,";"),TEXTJOIN(";",0,FILTER(y,COUNTIF(F2:F4,y)=0)))))
Dynamic array formulas.
 
Upvote 0
Solution
Hi JvdV,

thank for the formula, it works perfectly for small data sets. However when I'm running it for 50 000 records, the results I get is "0" in all the rows. Do you know if there's a way to overcome this?
 
Upvote 0
After loading for a while the zeros turned into an error: #SPILL!

I'm looking into the reason, but if you have any suggestions, please let me know.

Many thanks
 
Upvote 0
You can try This custom formula. the first argument is the cell you want to remove strings from, 2nd argument is the strings you want to remove.
VBA Code:
Function Reg(rng As Range, Pat As Range)
        Dim Regex As Object
        Set Regex = CreateObject("vbscript.regexp")
        Dim Fin, Ra, s
        Fin = Pat
        Dim k As Long
        ReDim Ra(1 To Pat.Cells.Count)
       
        For Each s In Fin
            k = k + 1
            Ra(k) = s
        Next s
        Dim mr As String: mr = Join(Ra, "")
       
        With Regex
        .Global = True
        .Pattern = "[" & mr & "];"
        Reg = .Replace(rng.Value, "")
        End With
       
End Function
 

Attachments

  • 1676025553895.png
    1676025553895.png
    18.3 KB · Views: 5
Upvote 0
After loading for a while the zeros turned into an error: #SPILL!

I'm looking into the reason, but if you have any suggestions, please let me know.

Many thanks
@GonzoB I've tested it myself on 50000 rows just now and worked fine. The spill error could indicate that you have data sitting in the way of the dynamic array. Make sure the column where you put this formula has enough empty rows for it to spill the results correctly.
 
Upvote 0
Hi JvdV,

thanks for looking into it. I could not find the reason, but somehow at the end I managed to run the formula against 90% of my records.

Have a nice day.
 
Upvote 0

Forum statistics

Threads
1,214,548
Messages
6,120,141
Members
448,948
Latest member
spamiki

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top