Collating data vertically not horizontally

rovert

New Member
Joined
Aug 4, 2009
Messages
22
Afternoon All,

Thank you in advance, i need help in presenting my data vertically and not horizontally. Fig1 is how my data is at the moment, however i need to present it like Fig2.

Fig1
KNrDriveshaftCV JointBoot KitHub Nuts
10447VA181LCV1381NBK14HN02
10447VA181LCV1159NBK14HN02
10447VA181LCV1381NBK650HN02
10447VA181LCV1159NBK650HN02
10447VA181LCV1381NCBK7000HN02
10447VA181LCV1159NCBK7000HN02
10447VA181LCV1381NSB04HN02
10447VA181LCV1159NSB04HN02
Fig2
Required Result
VA181LHub NutsHN02
VA181LBoot KitBK14
VA181LBoot KitBK650
VA181LBoot KitCBK7000
VA181LBoot KitSB04
VA181LCV JointCV205N
VA181LCV JointCV1159N
VA181LCV JointCV1381N

<colgroup><col><col><col><col><col></colgroup><tbody>
</tbody>
 

Excel Facts

Create a chart in one keystroke
Select the data and press Alt+F1 to insert a default chart. You can change the default chart to any chart type
Try this

I guess the data starts on sheet 1 in row 2.
Change the name sheet1 for the sheet with data and the name sheet2 for the sheet with the result.


Code:
Sub Collating_data()
  Dim sh1 As Worksheet, sh2 As Worksheet, i As Long, llave As String, ky As Variant, dict As Object
  Set sh1 = Sheets("[COLOR=#ff0000]Sheet1[/COLOR]")
  Set sh2 = Sheets("[COLOR=#ff0000]Sheet2[/COLOR]")
  sh2.Rows("2:" & Rows.Count).ClearContents
  Set dict = CreateObject("scripting.dictionary")
  For i = 2 To sh1.Range("B" & Rows.Count).End(xlUp).Row
    dict.Item(sh1.Cells(i, "B") & "|" & sh1.Cells(1, "E") & "|" & sh1.Cells(i, "E")) = Empty
    dict.Item(sh1.Cells(i, "B") & "|" & sh1.Cells(1, "D") & "|" & sh1.Cells(i, "D")) = Empty
    dict.Item(sh1.Cells(i, "B") & "|" & sh1.Cells(1, "C") & "|" & sh1.Cells(i, "C")) = Empty
  Next
  sh2.Range("A2").Resize(dict.Count) = Application.Transpose(dict.Keys)
  sh2.Range("A:A").TextToColumns sh2.Range("A1"), xlDelimited, xlNone, , , , , , True, "|"
End Sub
 
Upvote 0

Forum statistics

Threads
1,215,425
Messages
6,124,822
Members
449,190
Latest member
rscraig11

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