Hi everyone,
I would badly need a macro to go from what you see on the "what_I_have" sheet to the "what_I_need" sheet in the attached file.
Basically, in this badly formatted file from which I need to start from, there are three "titles" for each column and I need to move two of these "titles" to the values of two new columns I need to create, so that in the end there is just one type of values in each column.
This is the beginning of the table:
Year year_1 year_1 Month January January MeasuresLevel Variable1 Variable2 type_1 continent_1 country_1 0 0 type_1 continent_2 country_2 0 0 type_2 continent_1 country_3 2 2 type_2 continent_2 country_4 0 0 type_3 continent_1 country_5 20 74 type_3 continent_2 country_6 22 123
As you can see "Year" and "Month" are like titles and I need to convert them to row values like this:
Year Month Type Continent Country Variable1 Variable2 year_1 January type_1 continent_1 country_1 0 0 year_1 January type_1 continent_2 country_2 0 0 year_1 January type_2 continent_1 country_3 2 2 year_1 January type_2 continent_2 country_4 0 0 year_1 January type_3 continent_1 country_5 20 74 year_1 January type_3 continent_2 country_6 22 123
Moreover, the starting file contains many years (and is therefore much longer than the example file I attach, which contains only 1 year).
Could anyone come up with a macro that does this?
I would be extremely grateful, doing this by hand is impossible because I have a lot of files and a lot of years of data.
Thanks a lot!
example.xlsx
Bookmarks