How to convert table into rows?

I have a spreadsheet with years (pop1970,pop1971, etc.) across the top and counties(state_county) down.
The intersection of each column and row is the population estimate for that state_county and year.
I need a macro that will create a row for each county_state and year and the population in this format:
county_state,year,population
Census-ExEx.xlsb
LVL 1
Alex CampbellAsked:
Who is Participating?
 
Matt NicholasBusiness AnalystCommented:
Hi Alex,

Attached using the solution from Subodh as above, check out Google and specifically "Unpivot Other Columns" function in Power Query.

You will love it!


M
Census-ExEx.xlsb
1
 
Subodh Tiwari (Neeraj)Excel & VBA ExpertCommented:
If you are using Excel-2010 or later, you may use Power Query, a free Add-In from Microsoft to get the data in the desired format.
Download it from the MS site and follow the instructions in the video to get the data in desired format.
The solution would be dynamic in nature i.e. if you add more data down the rows, all you need to do is right click on the new table created by Power Query and choose Refresh and it will be updated accordingly.
Census-ExEx.xlsb
RowsToColumns_PowerQuery.mp4
0
 
Subodh Tiwari (Neeraj)Excel & VBA ExpertCommented:
@Matt

It seems I misunderstood the requirement and assumed data on CompleteList as the desired output. My bad.


@ Alex
Please find the updated video to follow the steps to achieve the desired output. :)
Census-ExEx-v2.xlsb
RowsToColumns_PowerQuery.mp4
1
 
Alex CampbellAuthor Commented:
Thanks to both Matt and Subodh for an amazing tool in Excel.
0
 
Subodh Tiwari (Neeraj)Excel & VBA ExpertCommented:
You're welcome Alex! Glad we could help.
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.