Taking header columns and switch the data to rows...

Siagon09

Board Regular
Joined
Feb 16, 2007
Messages
56
Hi there,

I have a datasheet with a lot of information. And the values split into 10-20 different columns which I don't need.

Instead, I want to have only 1 column with values and the data currently in the headers should be listed in each row.

So for example, this is what I currently see. Each X is header column with values
x1 x2 x3
A
b
c
d

I want to see it as
Values
A x1
B x2
C x2
D x3
E x1

Is there a simple and quick way to do this? Let me know if this is not clear. Thanks!!

-Sia
 

Excel Facts

Whats the difference between CONCAT and CONCATENATE?
The newer CONCAT function can reference a range of cells. =CONCATENATE(A1,A2,A3,A4,A5) becomes =CONCAT(A1:A5)
Copy the row, click in an empty cell in column A, Edit > Paste Special, check Transpose then click OK.
 
Upvote 0
I don't think it is as simple as transpose

There's hundreds of rows already with other data in each column. The value section is split be another 10-20 columns with values all over the places. Hundreds of cells in each column.

Transpose would just switch the headers to rows but I need the values to follow as well.

How would I transpose the headers and keep the values in only 1 column?

Sorry the title of my thread is not really correct for this question. I just don't know how to phrase it.
 
Upvote 0
You need to post a bigger sample showing what you have and what you want.
 
Upvote 0
Last edited:
Upvote 0
ignore the above post. i think i figured out how to imbed this now
Excel Workbook
ABCDEFGHI
1VendorCost TypeCost DescriptionGL AccountBus Unit 1Bus unit 2Bus Unit 3Bus Unit 4Bus Unit 5
2Vendor AConsultantAutomation60190015$ 100$ 5$ 3,000
3Vendor BSoftwareSecurity Scans60190015$ 200$ 10,000
4Vendor CHarwareOnshore60190015$ 5,000$ 20,000
5Vendor DOtherOffshore60190015$ 4,000$ 2,000
6Vendor ESoftwareMisc60190015$ 100
7Vendor FConsultantScheduling60190015$ 300$ 1,500
8Vendor GConsultantStorage60190015
Sheet1
Excel 2003



As you can see the headers in green (Bus Unit 1,2,3 etc). There are about 20 or so of these. I want to create another column specifically for the Bus Units and one consolidated line for the $ values.

This is what I want the above to actually look like:
Excel Workbook
ABCDEF
1VendorCost TypeCost DescriptionGL AccountBU'sAmount
2Vendor AConsultantAutomation60190015Bus Unit 1$ 100
3Vendor AConsultantAutomation60190015Bus Unit 3$ 5
4Vendor AConsultantAutomation60190015Bus Unit 4$ 3,000
5Vendor BSoftwareSecurity Scans60190015Bus unit 2$ 200
6Vendor BSoftwareSecurity Scans60190015Bus Unit 5$ 10,000
7Vendor CHarwareOnshore60190015Bus Unit 3$ 5,000
8Vendor CHarwareOnshore60190015Bus Unit 5$ 20,000
9Vendor DOtherOffshore60190015Bus unit 2$ 4,000
10Vendor DOtherOffshore60190015Bus Unit 3$ 2,000
11Vendor ESoftwareMisc60190015Bus Unit 3$ 100
12Vendor FConsultantScheduling60190015Bus Unit 1$ 300
13Vendor FConsultantScheduling60190015Bus Unit 4$ 1,500
14Vendor GConsultantStorage60190015
Sheet2
Excel 2003
 
Upvote 0
Try

Code:
Sub XPose()
Dim LR As Long, LC As Long, i As Long, j As Long
Sheets("Sheet2").Range("A1:F1").Value = Array("Vendor", "Cost Type", "Cost Description", "GL Account", "BU's", "Amount")
With Sheets("Sheet1")
    LR = .Cells.Find(What:="*", SearchDirection:=xlPrevious, SearchOrder:=xlByRows).Row
    LC = .Cells.Find(What:="*", SearchDirection:=xlPrevious, SearchOrder:=xlByColumns).Column
    For i = 2 To LR
        For j = 5 To LC
            If .Cells(i, j).Value <> "" Then
                Sheets("Sheet2").Range("A" & Rows.Count).End(xlUp).Offset(1).Resize(, 4).Value = .Range(.Cells(i, 1), .Cells(i, 4)).Value
                Sheets("Sheet2").Range("E" & Rows.Count).End(xlUp).Offset(1).Value = .Cells(1, j).Value
                Sheets("Sheet2").Range("F" & Rows.Count).End(xlUp).Offset(1).Value = .Cells(i, j).Value
            End If
        Next j
    Next i
End With
End Sub
 
Upvote 0

Forum statistics

Threads
1,224,518
Messages
6,179,259
Members
452,901
Latest member
LisaGo

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