need help on a VBA code

%3CLINGO-SUB%20id%3D%22lingo-sub-2807851%22%20slang%3D%22en-US%22%3Eneed%20help%20on%20a%20VBA%20code%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-2807851%22%20slang%3D%22en-US%22%3E%3CP%3EHi%20All%2C%26nbsp%3B%3C%2FP%3E%3CP%3Ecan%20someone%20please%20help%20with%20the%20following%20logic%20that%20I%20would%20need%20in%20VBA%3A%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3Esheet1-4%3A%20row%20data%20with%20coulmn%20headings%3C%2FP%3E%3CP%3Esheet5%3A%20summary%20table%20with%204%20rows%20of%20column%20headings%20representing%20the%20coloumn%20headings%20of%20sheet1-4%20respectively%20(there%20are%20empty%20cells%20in%20some%20of%20the%20headings)%26nbsp%3B%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EI%20would%20need%20a%20macro%20that%20searches%20sheet5%20column%20headings%20in%20rows%201%20to%204%2C%20finds%20them%20in%20sheet%201-4%20respectively%20and%20copy%20pastes%20the%20respective%20columns%20into%20sheet5%20under%20the%20respective%20heading%20for%20sheet1%20starting%20in%20row%202%2C%20for%20sheet2%20starting%20in%20row%20100%2C%20for%20sheet3%20staritng%20row%20200%20and%20for%20sheet4%20starting%20in%20row%20300.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EI%20very%20much%20appreciate%20your%20help%20with%20this.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-LABS%20id%3D%22lingo-labs-2807851%22%20slang%3D%22en-US%22%3E%3CLINGO-LABEL%3EMacros%20and%20VBA%3C%2FLINGO-LABEL%3E%3C%2FLINGO-LABS%3E%3CLINGO-SUB%20id%3D%22lingo-sub-2808626%22%20slang%3D%22en-US%22%3ERe%3A%20need%20help%20on%20a%20VBA%20code%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-2808626%22%20slang%3D%22en-US%22%3EWhich%20Excel%20version%20are%20you%20using%20exactly%3F%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-2808676%22%20slang%3D%22en-US%22%3ERe%3A%20need%20help%20on%20a%20VBA%20code%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-2808676%22%20slang%3D%22en-US%22%3EOffice%202016%3C%2FLINGO-BODY%3E
New Contributor

Hi All, 

can someone please help with the following logic that I would need in VBA:

 

sheet1-4: row data with coulmn headings

sheet5: summary table with 4 rows of column headings representing the coloumn headings of sheet1-4 respectively (there are empty cells in some of the headings) 

 

I would need a macro that searches sheet5 column headings in rows 1 to 4, finds them in sheet 1-4 respectively and copy pastes the respective columns into sheet5 under the respective heading for sheet1 starting in row 2, for sheet2 starting in row 100, for sheet3 staritng row 200 and for sheet4 starting in row 300.

 

I very much appreciate your help with this.

 

 

5 Replies
Which Excel version are you using exactly?
Office 2016
You could do this by adding three queries to your file (Data, New Query button).
How can i merge tables there with headings that I need to link first (define which column heading in one table should be the equivalent of same with different name in another table)?
For each of the four sheets:
- You select the correct source data area
- Data, From Table
- In the right-hand pane, change the name to something relevant like qrySheet_1
- Now reorder the columns so they match the sheet you are currently targeting
- Delete any columns you don't need
- Rename any columns that need renaming
- Once you're happy, click the arrow below "Close & Load" and choose "Close & Load to..."
- In the next dialog select "Table" and select where you want the results to appear
- Do this for all four.
Now if your source data changes, just click the RefreshAll button.