(Solved) – Grouping two columns to shrink row count by comparing | code optimization

(solved)-–-grouping-two-columns-to-shrink-row-count-by-comparing-|-code-optimization

I try to find a vba solution for the following problem:

I have two columns and try to group column1 in a comma separate way to have less rows.

e.g.

example:

enter image description here

I tried this, and it worked – but It take too long (about 300.000 Rows). Is there any better solution that task?

*Its just one part of my macro

For Each r In fr
    If st = "" Then
        st = Application.WorksheetFunction.Clean(Trim(ws.Cells(r.row, "L").Value))
    Else
        If Not IsInArray(Split(st, ","), ws.Cells(r.row, "L").Value) Then
            st = st & ", " & Application.WorksheetFunction.Clean(Trim(ws.Cells(r.row, "L").Value))
        End If
    End If
    If usrCheck = True Then
        If str = "" Then
            str = Application.WorksheetFunction.Clean(Trim(ws.Cells(r.row, "A").Value))
        Else
            If Not IsInArray(Split(str, ","), ws.Cells(r.row, "A").Value) Then
                str = str & ", " & Application.WorksheetFunction.Clean(Trim(ws.Cells(r.row, "A").Value))
            End If
        End If
    End If
Next

Leave a Reply

Your email address will not be published. Required fields are marked *