Table values to single row for each value

jerryr0125

New Member
Joined
May 14, 2017
Messages
6
Hi I am looking to take data that is structured in a table and create a spreadsheet with each data point as a row.

Example - Start Data

ID1/25/182/14/183/11/18
FS01100.2598.719.07
FS02342.2383.6582.14
FS0312.4742.3434.48
FS04144.6818.2376.17

<colgroup><col style="width:65pt" width="65" span="4"> </colgroup><tbody>
</tbody>


End Data

IDDateAmount
FS011/25/18100.25
FS012/14/1898.7
FS013/11/1819.07
FS021/25/18342.23
FS022/14/1883.65
FS023/11/1882.14
FS031/25/1812.4
FS032/14/18742.34
FS033/11/1834.48
FS041/25/18144.68
FS042/14/1818.23
FS043/11/1876.17

<colgroup><col style="width:65pt" width="65" span="3"> </colgroup><tbody>
</tbody>


thoughts ? Jerry<style>table { }td { padding-top: 1px; padding-right: 1px; padding-left: 1px; color: black; font-size: 12pt; font-weight: 400; font-style: normal; text-decoration: none; font-family: Calibri, sans-serif; vertical-align: bottom; border: medium none; white-space: nowrap; }.xl63 { }.xl64 { background: yellow none repeat scroll 0% 0%; }</style><style>table { }td { padding-top: 1px; padding-right: 1px; padding-left: 1px; color: black; font-size: 12pt; font-weight: 400; font-style: normal; text-decoration: none; font-family: Calibri, sans-serif; vertical-align: bottom; border: medium none; white-space: nowrap; }.xl63 { background: yellow none repeat scroll 0% 0%; }.xl64 { background: yellow none repeat scroll 0% 0%; }</style>
 

Excel Facts

How can you turn a range sideways?
Copy the range. Select a blank cell. Right-click, Paste Special, then choose Transpose.
For reference this has been cross-posted here
 
Last edited:
Upvote 0
The code below will transform a "table" starting in A1 to the version (see below) starting in F1.
Excel Workbook
ABCDEFGH
1ID1/25/20182/14/20183/11/2018IDDateAmount
2FS01100.2598.719.07FS011/25/2018100.25
3FS02342.2383.6582.14FS012/14/201898.7
4FS0312.4742.3434.48FS013/11/201819.07
5FS04144.6818.2376.17FS021/25/2018342.23
6FS022/14/201883.65
7FS023/11/201882.14
8FS031/25/201812.4
9FS032/14/2018742.34
10FS033/11/201834.48
11FS041/25/2018144.68
12FS042/14/201818.23
13FS043/11/201876.17
Sheet1



Code:
Sub jerryr0125()
Dim R As Range, NxRw As Long, i As Long
Set R = Range("A1").CurrentRegion
Application.ScreenUpdating = False
Columns("F:H").ClearContents
Range("F1:H1").Value = Array("ID", "Date", "Amount")
For i = 2 To R.Columns(1).Cells.Count
    NxRw = Cells(Rows.Count, "F").End(xlUp).Row + 1
    Cells(NxRw, "F").Resize(R.Rows(1).Cells.Count - 1).Value = R.Columns(1).Cells(i, 1).Value
    Cells(NxRw, "G").Resize(R.Rows(1).Cells.Count - 1).Value = Application.Transpose(R.Rows(1).Offset(0, 1).Resize(, R.Rows(1).Cells.Count - 1).Value)
    Cells(NxRw, "H").Resize(R.Rows(1).Cells.Count - 1).Value = Application.Transpose(R.Rows(i).Offset(0, 1).Resize(, R.Rows(1).Cells.Count - 1).Value)
Next i
Application.ScreenUpdating = True
End Sub
 
Upvote 0
or you can try PowerQuery (Get&Transform)

ID1/25/182/14/1803/11/2018IDDateAmount
FS01
100.25​
98.7​
19.07​
FS01
25/01/2018​
100.25​
FS02
342.23​
83.65​
82.14​
FS01
14/02/2018​
98.7​
FS03
12.4​
742.34​
34.48​
FS01
11/03/2018​
19.07​
FS04
144.68​
18.23​
76.17​
FS02
25/01/2018​
342.23​
FS02
14/02/2018​
83.65​
FS02
11/03/2018​
82.14​
FS03
25/01/2018​
12.4​
FS03
14/02/2018​
742.34​
FS03
11/03/2018​
34.48​
FS04
25/01/2018​
144.68​
FS04
14/02/2018​
18.23​
FS04
11/03/2018​
76.17​

Code:
[SIZE=1]// Table1
let
    Source = Excel.CurrentWorkbook(){[Name="Table1"]}[Content],
    UnPivot = Table.Unpivot(Source, {"1/25/18", "2/14/18", "03/11/2018"}, "Attribute", "Value"),
    Type = Table.TransformColumnTypes(UnPivot, {{"Attribute", type date}}, "en-US"),
    Rename = Table.RenameColumns(Type,{{"Attribute", "Date"}, {"Value", "Amount"}})
in
    Rename[/SIZE]

I'm not using US date format so result is in dd/mm/yyyy

---
what is the heck with BB code? size for table is 1 but as I see table is much larger :(
 
Last edited:
Upvote 0
@jerryr0125
For future reference while we do not prohibit Cross-Posting on this site, we do ask that you please mention you are doing so and provide links in each of the threads pointing to the other thread (see rule 13 here along with the explanation: Forum Rules).
This way, other members can see what has already been done in regards to a question, and do not waste time working on a question that may already be answered.
 
Upvote 0

Forum statistics

Threads
1,214,849
Messages
6,121,925
Members
449,056
Latest member
denissimo

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