How do I sort this Data?

jpeavler

New Member
Joined
Jul 26, 2016
Messages
2
Hello! I am trying to figure out a way to sort raw data into a desired format.

This is the format of the raw data:

Raw Data
NameParameterValue
A100Temp5
A100Press10
A100Flow15
B200Temp20
B200Press25
B200Flow30
C300Temp35
C300Press40
C300Flow45

<tbody>
</tbody>

This is the format that I want after the data is sorted:

Sorted Data
NameTempPressFlow
A10051015
B200202530
C300354045

<tbody>
</tbody>


Any suggestions are appreciated. Thanks!
 

Excel Facts

Does the VLOOKUP table have to be sorted?
No! when you are using an exact match, the VLOOKUP table can be in any order. Best-selling items at the top is actually the best.
Hello! I am trying to figure out a way to sort raw data into a desired format.

This is the format of the raw data:

Raw Data
NameParameterValue
A100Temp5
A100Press10
A100Flow15
B200Temp20
B200Press25
B200Flow30
C300Temp35
C300Press40
C300Flow45

<tbody>
</tbody>

This is the format that I want after the data is sorted:

Sorted Data
NameTempPressFlow
A10051015
B200202530
C300354045

<tbody>
</tbody>


Any suggestions are appreciated. Thanks!

Hi,

Go to the insert tab. Choose insert table > pivot table.

Select everything but Raw Data. Hit enter.

Place Name in the rows section in the field list of the pivot table. Place Parameter in the Columns section of the field list. Place Values in the values table of the field list.

Hope this helps.
 
Upvote 0
You can also run a macro.
If your data start in cell A1, just run this:
Code:
Sub rearrange()

Dim d1 As Object, d2 As Object, c()
Dim a, u1, u2, i As Long, n As Long

Set d1 = CreateObject("scripting.dictionary")
Set d2 = CreateObject("scripting.dictionary")
a = Range("A1").CurrentRegion
n = UBound(a)
ReDim c(1 To n, 1 To n)

For i = 2 To n
    u1 = a(i, 1)
    u2 = a(i, 2)
    If Not d1.exists(u1) Then d1(u1) = d1.Count + 1
    If Not d2.exists(u2) Then d2(u2) = d2.Count + 1
    c(d1(u1), d2(u2)) = c(d1(u1), d2(u2)) & " " & a(i, 3)
Next i

[e1] = "Sorted Data": [e2] = "Name"
[e3].Resize(d2.Count, 1) = Application.Transpose(d1.keys)
[f2].Resize(1, d1.Count) = d2.keys
[f3].Resize(d1.Count, d2.Count) = c

End Sub
 
Upvote 0
Thank you. That did the trick perfectly. I also formatted my raw data as a named table and then I used the named table for the data range when setting up the pivot table. This allowed me to have a dynamic range for my pivot table so that I did not end up with (blank) columns or rows in my pivot table. That was useful for my application. Thanks again for the tip.
 
Upvote 0

Forum statistics

Threads
1,215,222
Messages
6,123,709
Members
449,118
Latest member
MichealRed

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