+ Reply to Thread
Results 1 to 8 of 8

Match different headings in different sheets and copy filtered data to correct heading

  1. #1
    Registered User
    Join Date
    12-15-2014
    Location
    Wales, UK
    MS-Off Ver
    365
    Posts
    66

    Match different headings in different sheets and copy filtered data to correct heading

    Good day,

    I have template sheets and a data sheet. Some of the headings differ between the data sheet and template sheets, as well as th position of them:
    example:
    headings.JPG

    So this is an example of what I'm trying to do:
    -Find "Format" heading in the datasheet
    -Copy filtered data under the "Format" heading
    -Find matching header position ("Ownership")in Template
    -Paste data as values under that heading
    -Go to next one I specify (I'll do this in the code)

    I've never done this one before if anyone has any ideas, please. The closest code I can change that I found is the following:

    Please Login or Register  to view this content.
    Last edited by Simone Fick; 03-29-2018 at 08:18 AM. Reason: Solved

  2. #2
    Forum Expert dflak's Avatar
    Join Date
    11-24-2015
    Location
    North Carolina
    MS-Off Ver
    365
    Posts
    7,920

    Re: Match different headings in different sheets and copy filtered data to correct heading

    This would go better with a sample workbook. The template and a data sheet or two plus a mock up of the desired output would be a great help.
    One spreadsheet to rule them all. One spreadsheet to find them. One spreadsheet to bring them all and at corporate, bind them.

    A picture is worth a thousand words, but a sample spreadsheet is more likely to be worked on.

  3. #3
    Registered User
    Join Date
    12-15-2014
    Location
    Wales, UK
    MS-Off Ver
    365
    Posts
    66

    Re: Match different headings in different sheets and copy filtered data to correct heading

    Hi,

    I've attached an example. About 4 sheets that are the templates where the data needs to go in, 1 sheet which is the "Data" and the "Header" sheet is normally not there, it's just to make it easier to show you which headings match which ones(Marked in green are the only ones I'll be using).

    Thank you for the help.
    Attached Files Attached Files

  4. #4
    Forum Expert dflak's Avatar
    Join Date
    11-24-2015
    Location
    North Carolina
    MS-Off Ver
    365
    Posts
    7,920

    Re: Match different headings in different sheets and copy filtered data to correct heading

    I did a couple of things:

    First I removed all the extra lines in the tables. Tables grow automatically as you add data so you don't have to add the extra lines. The tables even "remember" formulas and formats and such.

    I renamed the tables to match the pages. I use this naming convention in the code.

    I also made a table out of the data so I could address whole columns at a time in the code, and made a table out of the heading names again because tables know how big they are, so if you add things to the "map" the code doesn't have to change.

    The code loops through the sheets, looks at the table headers in the templates and tries to find it in Table_map. If it find it, it finds the corresponding table header name in data and copies it to the template table column.
    Attached Files Attached Files

  5. #5
    Registered User
    Join Date
    12-15-2014
    Location
    Wales, UK
    MS-Off Ver
    365
    Posts
    66

    Re: Match different headings in different sheets and copy filtered data to correct heading

    Hi dflak,

    The code works perfectly for one of my workbooks, thank you!
    But not when I try to add just a little bit to it on another. Below is the new added code(Green) and where I get the error(Red). Eroor message states that sub or function not defined.

    Please Login or Register  to view this content.

  6. #6
    Forum Expert dflak's Avatar
    Join Date
    11-24-2015
    Location
    North Carolina
    MS-Off Ver
    365
    Posts
    7,920

    Re: Match different headings in different sheets and copy filtered data to correct heading

    In my code the TableName is base on the sheet name.
    Please Login or Register  to view this content.
    Since you are creating a table with a known name then change this line to:
    Please Login or Register  to view this content.

  7. #7
    Registered User
    Join Date
    12-15-2014
    Location
    Wales, UK
    MS-Off Ver
    365
    Posts
    66

    Re: Match different headings in different sheets and copy filtered data to correct heading

    I didn't have to change the code as mentioned above. I realized you had another module to call "ClearTable", so I added that to my new workbook. With my new code still the same. But now I get the following error:

    error '1004'
    Method 'Range' of object'_Global_Failed


    I marked in red where the error occurs in the code below.

    Please Login or Register  to view this content.

  8. #8
    Registered User
    Join Date
    12-15-2014
    Location
    Wales, UK
    MS-Off Ver
    365
    Posts
    66

    Re: Match different headings in different sheets and copy filtered data to correct heading

    Rookie error. Fixed it thanks.
    I forgot to name my data table.

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Copy Filtered data to other sheets
    By Wiking in forum Excel General
    Replies: 0
    Last Post: 05-17-2016, 05:17 AM
  2. [SOLVED] Error pasting data (including headings) into an excel table when heading is variable
    By L plates in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 03-10-2016, 01:20 PM
  3. VBA Macro - Copy and paste data match by column headings
    By weijianhk in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 02-26-2015, 11:05 PM
  4. Replies: 0
    Last Post: 04-11-2014, 06:07 PM
  5. Replies: 6
    Last Post: 12-18-2013, 09:11 PM
  6. [SOLVED] fill down pre-existing headings so that data is able to be filtered
    By natnano in forum Excel General
    Replies: 3
    Last Post: 08-02-2013, 11:51 AM
  7. Copy/Paste filtered data from one sheet to another with only matched column headings
    By archerrc in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 04-08-2013, 05:00 PM

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1