I looked around for something to help me unpivot data and couldn't find anything to meet what I needed. So I created this macro and I am sharing it so others can use it and to see if there are any improvements I could make.
This unpivot is specifically made for data that has several columns of information before the date columns start. So I may have a column for name, a column for department, a column for accounting cost center, and then I would start having columns for each month with data filled in for sales dollars for each of those months. While this is a great way to visually present data, it is horrible to try to analyze it in this format.
Some codes I have seen unpivot by looking at each cell and deciding what to do with it. In my case I have to unpivot data that has several thousand rows with several years of date columns off to the right. Looking cell by cell simply doesn't work with that much data to transform. This macro uses arrays to transform the data in larger chunks, looking at whole rows instead of looking cell by cell. I tested it with 2,000 rows of data and 24 columns of dates off to the right and it worked in a flash.
That said I am sure there can be improvements made to the code. If you have ideas to improve it, make a comment, if you need something like this, use it.
Bookmarks