Split items into Rows

GreyFox8991

New Member
Joined
Jul 20, 2022
Messages
21
Office Version
  1. 2016
Platform
  1. Windows
Greetings Excel Community,

Below I have some Test data where the Unique ID has a relationship with the "Value" column. For each UniqueID, there must be a corresponding row from the "value" Column. What I am trying to accomplish is a formula or VBA Script that will split the UniqueID into its respective column followed by the value in the "value" column related to the ID. For example Unique ID 123 should have five values with 101,102,103,104,105 in its respective row/column. A caveat to this would be if the VBA Script/Formula take into consideration date formatting if possible. Any insight would be greatly appreciated... I am including some sample data for context. Please review the "End Results" for what the result should possibly be:

Book9
AB
1Unformatted Data
2Unique IdValue
3123101,102,103,104,105
4456200,201,203,204,205
578909/11/2023,09/12/2023,09/13/2023
610111210/01/2023,10/02/2023,10/03/2023
7
8
9
10End Result
11UniqueIDValue
12123101
13123102
14123103
15123104
16123105
17456200
18456201
19456203
20456204
21456205
227899/11/2023
237899/12/2023
247899/13/2023
2510111210/1/2023
2610111210/2/2023
2710111210/3/2023
Sheet1
 

Excel Facts

Show numbers in thousands?
Use a custom number format of #,##0,K. Each comma after the final 0 will divide the displayed number by another thousand
Here is one way.

ROWSPLIT
ABCDE
1Unique IdValueUnique IdValue
2123101,102,103,104,105123101
3456200,201,203,204,205123102
478909/11/2023,09/12/2023,09/13/2023123103
510111210/01/2023,10/02/2023,10/03/2023123104
6123105
7456200
8456201
9456203
10456204
11456205
127899/11/2023
137899/12/2023
147899/13/2023
1510111210/1/2023
1610111210/2/2023
1710111210/3/2023
Sheet1


VBA Code:
Sub ROWSPLIT()
Dim RNG As Range:       Set RNG = Range("A2:B" & Range("A" & Rows.Count).End(xlUp).Row)
Dim AR() As Variant:    AR = RNG.Value2
Dim AL As Object:       Set AL = CreateObject("System.Collections.ArrayList")
Dim SP() As String

For i = 1 To UBound(AR)
    SP = Split(AR(i, 2), ",")
    For j = 0 To UBound(SP)
        AL.Add Join(Array(AR(i, 1), SP(j)), ";")
    Next j
Next i

Set RNG = Range("D2").Resize(AL.Count)

With RNG
    .Value = Application.Transpose(AL.toArray)
    .TextToColumns DataType:=xlDelimited, Semicolon:=True
End With

End Sub
 
Upvote 1
Solution
Greetings lrobbo314,

Thank you for your reply... I have tested this and works as noted. Appreciate your diligent suggestion!
 
Upvote 0

Forum statistics

Threads
1,223,885
Messages
6,175,187
Members
452,616
Latest member
intern444

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