Get Mirrored Column "Structure" in 2 Sheets

Closed
SidK Posts 6 Registration date Wednesday April 29, 2015 Status Member Last seen October 13, 2015 - Oct 13, 2015 at 10:35 AM
rizvisa1 Posts 4478 Registration date Thursday January 28, 2010 Status Contributor Last seen May 5, 2022 - Oct 16, 2015 at 01:43 PM
So this turned out to be a complete mind-breaker for me.

Thanks to the help I previously received on this forum I can already manage (and enjoy!) quite a lot of basic VBA coding by myself. For which I am more than grateful. However this one still looks one leap too far. It has me completely puzzled.


I have two sheets in one workbook with at about 100 columns.
Most column headers appear in both sheets, but some column headers from sheet 1 do not appear in sheet 2 and vice versa.

What I want is to get both sheets exactly equal in their "column structure"
In short the missing columns should become present in both sheets, so that both contain exactly the same number of columns and each column is in exactly the same spot as in the other sheet.

Simplified in an example:

Original sheet 1:
(misses columns with heading C and E)


Original sheet 2:
(misses column with heading A)



Desired result sheet 1:
(added the missing column headings C and A)




Desired result sheet 2:
(added the missing column heading A)




Please note that no values from inside the columns need to be transferred, except for the heading and that the order needs to be exactly identical in both sheets.


Until now I only managed to get the columns sorted ascending based on their heading name in both sheets. I have not managed to identify the missing columns and add them to the sheet in which they are missing.


So I really, really hope one of you can help me out with this.
Thanks already very much in advance!
Related:

1 response

rizvisa1 Posts 4478 Registration date Thursday January 28, 2010 Status Contributor Last seen May 5, 2022 766
Oct 16, 2015 at 01:43 PM
in your example you have columns in order. how it would be in real

one way to do what you want is
1. create a temp sheet
2. copy all the column header from sheet sheet1 and paste in temp sheet by transposing column to rows
3. copy all the column header from sheet2 and paste in temp sheet after the last used row from previous paste
4. apply advance filter to get the unique rows
now you know what is super set of column header it
you can use that info to insert new columns as needed
0