Transpose Data in a Different Format

Stephen_IV

Well-known Member
Joined
Mar 17, 2003
Messages
1,180
Office Version
  1. 365
  2. 2019
Platform
  1. Windows
I am trying to Transpose Data in a Different Format, please see below. I am trying to take the data from columns A,B, and C and put it into Columns E:K. Any help would be appreciated. Thanks in advance Stephen.


Book2
ABCDEFGHIJK
1IDClassNeeds123456
277716,14,157776,14,156,14,155,14,155,14,155,21,225,15,18
377726,14,1588814,15,2614,1514,1514,1514,1514,15
477735,14,1599914,1514,1514,1514,1514,15
577745,14,1544412,13,1612,13,1712,13,18
677755,21,22
777765,15,18
8888114,15,26
9888214,15
10888314,15
11888414,15
12888514,15
13888614,15
14999114,15
15999314,15
16999414,15
17999514,15
18999614,15
19444112,13,16
20444312,13,17
21444512,13,18
Sheet1
 

Excel Facts

Which lookup functions find a value equal or greater than the lookup value?
MATCH uses -1 to find larger value (lookup table must be sorted ZA). XLOOKUP uses 1 to find values greater and does not need to be sorted.
Try this :- Results start "E1"
Code:
[COLOR="Navy"]Sub[/COLOR] MG14Apr07
[COLOR="Navy"]Dim[/COLOR] Rng [COLOR="Navy"]As[/COLOR] Range, Dn [COLOR="Navy"]As[/COLOR] Range, n [COLOR="Navy"]As[/COLOR] [COLOR="Navy"]Long[/COLOR]
[COLOR="Navy"]Dim[/COLOR] Ac [COLOR="Navy"]As[/COLOR] [COLOR="Navy"]Integer[/COLOR]
[COLOR="Navy"]Set[/COLOR] Rng = Range(Range("A2"), Range("A" & rows.Count).End(xlUp))
ReDim ray(1 To Rng.Count, 1 To 7)
[COLOR="Navy"]For[/COLOR] Ac = 1 To 7
ray(1, Ac) = IIf(Ac = 1, "ID/Class", Ac - 1)
[COLOR="Navy"]Next[/COLOR] Ac
n = 1
[COLOR="Navy"]With[/COLOR] CreateObject("scripting.dictionary")
.CompareMode = vbTextCompare
[COLOR="Navy"]For[/COLOR] [COLOR="Navy"]Each[/COLOR] Dn [COLOR="Navy"]In[/COLOR] Rng
    [COLOR="Navy"]If[/COLOR] Not .Exists(Dn.value) [COLOR="Navy"]Then[/COLOR]
        n = n + 1
        .Add Dn.value, n
        ray(n, 1) = Dn.value: ray(n, Dn.Offset(, 1) + 1) = Dn.Offset(, 2)
    [COLOR="Navy"]Else[/COLOR]
         ray(.Item(Dn.value), 1) = Dn.value: ray(.Item(Dn.value), Dn.Offset(, 1) + 1) = Dn.Offset(, 2)
    [COLOR="Navy"]End[/COLOR] If
[COLOR="Navy"]Next[/COLOR] Dn
Range("E1").Resize(.Count + 1, 7) = ray
[COLOR="Navy"]End[/COLOR] With
[COLOR="Navy"]End[/COLOR] [COLOR="Navy"]Sub[/COLOR]
Regards Mick
 
Upvote 0

Forum statistics

Threads
1,224,566
Messages
6,179,558
Members
452,928
Latest member
101blockchains

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