+ Reply to Thread
Results 1 to 6 of 6

Copy data from Main sheet to target sheets according to row header and target sheet header

  1. #1
    Forum Contributor
    Join Date
    07-14-2012
    Location
    Belgium/UK
    MS-Off Ver
    Excel 2003
    Posts
    111

    Copy data from Main sheet to target sheets according to row header and target sheet header

    Hello,

    Thanks to people on this forum I received the following code:
    Please Login or Register  to view this content.
    It works perfectly, but only for a single day. It takes the data from my index sheet and places it next the names in the corresponding sheets, which have the same name as the top row.

    As soon as I import data with more than 1 day, or where someone has been off in the middle of the week or not logged in,... anything that would interrupt with a 5 day system (5 days, 5 figures), the data becomes "corrupted" after running the macro.

    In the sample sheets that I have attached, are 2 names from which I removed 2 days of entries. All Target sheets have a date on top. The idea is obviously that all data is corresponding with name and date (which is fine if it is a single entry).

    On the "AfterSample" I manually added the expected result to clarify the bunch of words above.

    Any help on the code, or advice is greatly appreciated.
    Attached Files Attached Files

  2. #2
    Forum Expert
    Join Date
    08-16-2015
    Location
    Antwerpen, Belgium
    MS-Off Ver
    2007-2016
    Posts
    2,380

    Re: Copy data from Main sheet to target sheets according to row header and target sheet he

    Try this one

    Please Login or Register  to view this content.
    Kind regards
    Leo

  3. #3
    Forum Contributor
    Join Date
    07-14-2012
    Location
    Belgium/UK
    MS-Off Ver
    Excel 2003
    Posts
    111

    Re: Copy data from Main sheet to target sheets according to row header and target sheet he

    Hello LeoTaxi,

    Thank you for your response.

    I imported your code into my full workbook and it debugged.

    Please Login or Register  to view this content.
    Do I leave this at 3, as my original code has it as 2(usernames)

    Please Login or Register  to view this content.
    For n = 9 , Do I change this to back to 2 or leave at 9? Originally n was pointing to the usernames in col 2

    Please Login or Register  to view this content.
    "mycol" returns "error2042".

  4. #4
    Forum Expert
    Join Date
    08-16-2015
    Location
    Antwerpen, Belgium
    MS-Off Ver
    2007-2016
    Posts
    2,380

    Re: Copy data from Main sheet to target sheets according to row header and target sheet he

    Code made for this file where it is working,

    from row 9 because the first username is @ row 9
    columns from 3 to 7, those columns have the data to transfer


    Kind regards
    Leo
    Attached Files Attached Files

  5. #5
    Forum Contributor
    Join Date
    07-14-2012
    Location
    Belgium/UK
    MS-Off Ver
    Excel 2003
    Posts
    111

    Re: Copy data from Main sheet to target sheets according to row header and target sheet he

    Hello Leo...

    My mistake. Row 2-8 are hidden as I used those to "populate" the top row on the target sheets (date). Should have mentioned that.
    After adding the dates manually (which I can do via a formula to update), the code works perfect.

    Just one extra question.
    Please Login or Register  to view this content.
    This changes my formulaes in the G column (which are dates). Is this supposed to happen? I am asking this as I am newish to VBA and never seen VBA change a formula within a given cell.

    Regards,

    Red

  6. #6
    Forum Expert
    Join Date
    08-16-2015
    Location
    Antwerpen, Belgium
    MS-Off Ver
    2007-2016
    Posts
    2,380

    Re: Copy data from Main sheet to target sheets according to row header and target sheet he

    Hello Red,

    yes this supposed to happen, with this date ( not the 1 in column A, or the previus in column G) we find the column in other sheets.


    Kind regards
    Leo

+ 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. [SOLVED] Macro - Data copy from one sheet to other according to the header name
    By Chocobo in forum Excel Programming / VBA / Macros
    Replies: 9
    Last Post: 03-08-2018, 11:42 PM
  2. [SOLVED] Based on Column Header find and copy data from one sheet to another
    By Sachy in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 08-31-2014, 10:00 AM
  3. Copy data from header to header in consolidation sheet
    By Ignesh in forum Excel Programming / VBA / Macros
    Replies: 8
    Last Post: 11-12-2013, 04:10 AM
  4. [SOLVED] for each sheet with first 3 char matching variable, copy column C to Target sheet unless..
    By Spyderz in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 11-11-2012, 08:17 AM
  5. Macro code to pull data from different sheets based on the header of the main sheet
    By Shanthuday in forum Excel Programming / VBA / Macros
    Replies: 8
    Last Post: 08-21-2012, 05:00 AM
  6. Copy Data from one sheet to another using header as key
    By nihitsk in forum Excel Programming / VBA / Macros
    Replies: 11
    Last Post: 03-24-2011, 06:45 AM

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