Efficiently turn large string into data fields using delimiters

fishstar0

New Member
Joined
Jul 8, 2020
Messages
1
Office Version
  1. 365
Platform
  1. Windows
Hello, I am trying to create as efficient a subroutine as possible to deconcatenate a large string based on predetermined delimiters and add the data into a place power query can access

I have several different tables of data which I am grabbing for and I want one versatile subroutine which I can pass the delimiters as arrays into

I am aware in advance how many rows I will end up with

My current main difficulty is that my expected table size is typically over 10000 lines and sometimes even larger making efficiency a bottleneck for the programs functionality

My questions are
1. Is there a more efficient way of getting the value between two known delimiters?
2. Is there a more efficient way of transferring to Power Query than an excel table?
3. Is there any way to further simplify this code?


VBA Code:
Sub ExtractData(LeftDelimiter() As String, RightDelimiter() As String,source as string, TotalRows as integer, ExcelDataTable as ListObject)

    Dim FirstSplit(TotalRows) As String

    ExcelDataTable.DataBodyRange.ClearContents
    ExcelDataTable.DataBodyRange.Rows.Delete
    
    For tableColumn = LBound(LeftDelimiter) To UBound(LeftDelimiter)
        RightCut() = Split(source, LeftDelimiter(tableColumm))

        For Row = 1 To UBound(RightCut) 'Because of the nature of the input, I don't want the first cut
            ExcelDataTable.ListRows.Add.Range(tableColumn + 1) =  "'" + Left(RightCut(Row), InStr(RightCut(Row), RightDelimiter(TableColumn) - 1)
        Next Row
    Next tableColumn

End Sub
 

Excel Facts

Can Excel fill bagel flavors?
You can teach Excel a new custom list. Type the list in cells, File, Options, Advanced, Edit Custom Lists, Import, OK
VBA Code looks tight to me, not much you can do when dealing with a large amount of data.
 
Upvote 0
Using XL2BB, would you upload a sample of your data and a mocked up solution so that we can play with the data in Power Query so that we can provide you with a solution that will speed things up. PQ is designed to handle large datasets quicklyl
 
Upvote 0

Forum statistics

Threads
1,214,770
Messages
6,121,447
Members
449,033
Latest member
Kcolwell16

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