Put Data into a dynamic array in VBA and split string into key value pairs

Viewed 38

I have some raw data below which I am trying to format in Excel Spreadsheet.

The Data is formated as below

The Data is formated as below

I need to format this data in VBA to where it looks like this.

I need the data to look like this.

The last row, "CTP Parameters", needs to be separated into key value pairs while the other information stays the same until the part number changes. This some of the code that I have in VBA. I know I need to put this information into a dynamic array. I am new to VBA though.

Sub SplitKeyPairs()
    'Variables
    Dim myString As String
    Dim kpArr() As String
    Dim i, j As Integer

    i = 2
    j = 2
    
    Do
        myString = Range("F" & i)
    

        'Split the string based on the line break
        For Each keypair In Split(myString, "~")
            'Split the keypair value
            kpArr = Split(keypair, "^")
        
            'Copy keys on B column and values on C column
            Range("G" & j) = kpArr(0)
            Range("H" & j) = Replace(kpArr(1), "~", "")

            j = j + 1

        Next

        i = i + 1
    Loop While Range("F" & i) <> ""
End Sub
0 Answers
Related