Group and Transpose Columns

carleo

New Member
Joined
Apr 1, 2004
Messages
13
How do I transpose as shown below?
I have to columns of data, Site number and Disc number. I have sorted by unique site number but I don't know how to transpose the data.
testing.xls
ABCDEF
1SiteDisc
210123
310124
4101222
5103111
6109125
7109126
8109129
9109189
10109222
11
12
13SiteDisc1Disc2Disc3Disc4Disc5
141012324222
15103111
16109125126129189222
Sheet1
 

Excel Facts

Pivot Table Drill Down
Double-click any number in a pivot table to create a new report showing all detail rows that make up that number
Hi Tom,

I stumbled upon this macro today and am hoping to use it myself, but I have a slightly different situation. I have three rows of data that I want to group and then transpose.
<table>
<tr>
<td>Name</td><td>Sub-Name</td><td>Issue</td>
</tr>
<tr>
<td>AAA</td><td>AAA SUB 1</td><td>Issue 1</td>
</tr>
<tr>
<td>AAA</td><td>AAA SUB 2</td><td>Issue 1</td>
</tr>
<tr>
<td>AAA</td><td>AAA SUB 3</td><td>Issue 2</td>
</tr>
<tr>
<td>BBB</td><td>BBB SUB 1</td><td>Issue 1</td>
</tr>
<tr>
<td>BBB</td><td>BBB SUB 2</td><td>Issue 3</td>
</tr>
</table>

Which I would want to group and transpose to look like:
<table>
<tr>
<td>Name</td><td>Sub-Name 1</td><td>Issue</td><td>Sub-Name 2</td><td>Issue</td><td>Sub-Name 3</td><td>Issue</td>
</tr>
<tr>
<td>AAA</td><td>AAA SUB 1</td><td>Issue</td><td>AAA SUB 2</td><td>Issue</td><td>AAA SUB 3</td><td>Issue</td>
</tr>
<tr>
<td>BBB</td><td>BBB SUB 1</td><td>Issue</td><td>BBB SUB 2</td><td>Issue</td>
</tr>
</table>

Would it be hard to modify the macro? I just haven't done much Excel in the past, hoping you might be able to provide some insight.

Thanks!
 
Upvote 0
Is there a way to do the exact opposite of the original thread question?

So go from

Site
1
2
3
4
5
101
23
24
222
103
111
*
*
109
125
126
129
189
222

<tbody>
</tbody>

to this

Site
Disc
101
23
101
24
101
222
103
111
109
125
109
126
109
129
109
189
109
222

<tbody>
</tbody>

any help would be extremely appreciated!!!
 
Upvote 0
If you want to do this with a macro, and your source data is always A2:B10, and you want to reorganize it starting in row 14 (with row 13 being headers), see if this comes close to what you want:

Sub Test1()
Application.ScreenUpdating = False
Range("13:65536").ClearContents
Dim w As Integer, x As Long, y As Range, z As Range
Set y = Range("A2:A10")
y.AdvancedFilter Action:=xlFilterCopy, CopyToRange:=Range("A13"), Unique:=True
For Each z In Range("A13:A" & Cells(Rows.Count, 1).End(xlUp).Row)
w = 2
With y
Dim u, v
Set u = .Find(z.Value, LookIn:=xlValues, LookAt:=xlWhole, MatchCase:=True)
If Not u Is Nothing Then
v = u.Address
Do
Cells(z.Row, w).Value = Cells(u.Row, u.Column + 1).Value
w = w + 1
Set u = .FindNext(u)
Loop While Not u Is Nothing And u.Address <> v
End If
End With
Next z
Dim LC As Long, i As Integer
LC = Cells.Find(What:="*", After:=[A1], SearchOrder:=xlByColumns, SearchDirection:=xlPrevious).Column
i = 1
Range("A13").Value = Range("A1").Value
For Each z In Range(Cells(13, 2), Cells(13, LC))
z.Value = "Disc" & i
i = i + 1
Next z
Application.ScreenUpdating = True
End Sub



This macro transposes the data set from long to wide. Is there a similar macro that transposes the data set from wide to long?
 
Upvote 0
Is there a way to do the exact opposite of the original thread question?

So go from

Site12345
1012324222
103111**
109125126129189222

<tbody>
</tbody>

to this

SiteDisc
10123
10124
101222
103111
109125
109126
109129
109189
109222

<tbody>
</tbody>

any help would be extremely appreciated!!!


I need to accomplish the same thing, but cannot seem to figure out how to do it.
 
Upvote 0

Forum statistics

Threads
1,215,987
Messages
6,128,125
Members
449,425
Latest member
NurseRich

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