Split records

vmjan02

Well-known Member
Joined
Aug 15, 2012
Messages
1,062
Office Version
  1. 365
  2. 2021
  3. 2019
  4. 2016
  5. 2013
I have this table and trying to get the outpus , but no luck tried different ways, as well.
Any vba to get the results.


NEPort Full NameOutPut1OutPut2OutPut3OutPut4OutPut5OutPut6OutPut7OutPut8
103-00_BDEHRD00OL0Frame:0/Slot:19/Port:0Frame:0/Slot:19/Port:0Frame:0/Slot:20/Port:0
103-00_BDEHRD00OL0Frame:0/Slot:20/Port:0
104-00_GBIRRD00OL0Frame:0/Slot:19/Port:0Frame:0/Slot:19/Port:0Frame:0/Slot:20/Port:0
104-00_GBIRRD00OL0Frame:0/Slot:20/Port:0
104-00_GBIRRD00OL1Frame:0/Slot:9/Port:0Frame:0/Slot:9/Port:0Frame:0/Slot:9/Port:1Frame:0/Slot:9/Port:2Frame:0/Slot:9/Port:3Frame:0/Slot:19/Port:0Frame:0/Slot:20/Port:0
104-00_GBIRRD00OL1Frame:0/Slot:9/Port:1
104-00_GBIRRD00OL1Frame:0/Slot:9/Port:2
104-00_GBIRRD00OL1Frame:0/Slot:9/Port:3
104-00_GBIRRD00OL1Frame:0/Slot:19/Port:0
104-00_GBIRRD00OL1Frame:0/Slot:20/Port:0
104-00_GBIRRD00OL5Frame:0/Slot:9/Port:0
104-00_GBIRRD00OL5Frame:0/Slot:9/Port:1
104-00_GBIRRD00OL5Frame:0/Slot:10/Port:0
104-00_GBIRRD00OL5Frame:0/Slot:10/Port:1
105-00_YMAMRD00OL0Frame:0/Slot:9/Port:0
105-00_YMAMRD00OL0Frame:0/Slot:9/Port:1
105-00_YMAMRD00OL0Frame:0/Slot:9/Port:2
105-00_YMAMRD00OL0Frame:0/Slot:9/Port:3
105-00_YMAMRD00OL0Frame:0/Slot:19/Port:0
105-00_YMAMRD00OL0Frame:0/Slot:20/Port:0
105-00_YMAMRD00OL1Frame:0/Slot:19/Port:0
105-00_YMAMRD00OL1Frame:0/Slot:20/Port:0
105-00_YMAMRD00OL2Frame:0/Slot:19/Port:0
105-00_YMAMRD00OL2Frame:0/Slot:20/Port:0
105-00_YMAMRD00OL5Frame:0/Slot:19/Port:0
105-00_YMAMRD00OL5Frame:0/Slot:20/Port:0
105-00_YMAMRD00OL7Frame:0/Slot:19/Port:0
105-00_YMAMRD00OL7Frame:0/Slot:20/Port:0
105-00_YMAMRD00OL8Frame:0/Slot:10/Port:0
105-00_YMAMRD00OL8Frame:0/Slot:10/Port:1
105-00_YMAMRD00OL8Frame:0/Slot:10/Port:2
105-00_YMAMRD00OL8Frame:0/Slot:10/Port:3
105-00_YMAMRD00OL8Frame:0/Slot:19/Port:0
105-00_YMAMRD00OL8Frame:0/Slot:19/Port:1
105-00_YMAMRD00OL8Frame:0/Slot:20/Port:0
105-00_YMAMRD00OL8Frame:0/Slot:20/Port:1
105-00_YMAMRD00OL9Frame:0/Slot:19/Port:0
105-00_YMAMRD00OL9Frame:0/Slot:20/Port:0
105-00_YMAMRD00OLAFrame:0/Slot:19/Port:0
105-00_YMAMRD00OLAFrame:0/Slot:20/Port:0
105-00_YMAMRD00OLCFrame:0/Slot:19/Port:0
105-00_YMAMRD00OLCFrame:0/Slot:20/Port:0
 

Excel Facts

Bring active cell back into view
Start at A1 and select to A9999 while writing a formula, you can't see A1 anymore. Press Ctrl+Backspace to bring active cell into view.
Assuming the records start in cell A2, the results in cell C2 onwards.

Try this:

VBA Code:
Sub split_records()
  Dim dic As Object
  Dim nCol As Long, nRow As Long, i As Long
  Dim a As Variant, b As Variant
 
  Set dic = CreateObject("Scripting.Dictionary")
  a = Range("A2", Range("B" & Rows.Count).End(3)).Value
  ReDim b(1 To UBound(a, 1), 1 To 100)
 
  For i = 1 To UBound(a, 1)
    If Not dic.exists(a(i, 1)) Then
      dic(a(i, 1)) = i
      nCol = 1
    Else
      nCol = nCol + 1
    End If
    b(dic(a(i, 1)), nCol) = a(i, 2)
  Next
 
  Range("C2").Resize(UBound(b, 1), UBound(b, 2)).Value = b
End Sub
 
Upvote 0
Solution

Forum statistics

Threads
1,215,903
Messages
6,127,651
Members
449,395
Latest member
Perdi

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