+ Reply to Thread
Results 1 to 7 of 7

Need dynamic macro to reformat data from one tab to another

  1. #1
    Forum Contributor
    Join Date
    09-12-2012
    Location
    Michigan
    MS-Off Ver
    Excel 2007
    Posts
    127

    Need dynamic macro to reformat data from one tab to another

    Can someone share the code I can try to reformat the data in the attached file from Sheet1 to the format in Sheet2?


    The code needs to work on source files that are dynamic, the number of rows and the number of columns in the file(on Sheet1) can change.

    Sheet1 would be the source data and Sheet2 represents the desired output. See notes on Sheet2 for other details about the output.

    Thanks in advance, S4
    Attached Files Attached Files

  2. #2
    Forum Expert p24leclerc's Avatar
    Join Date
    07-05-2010
    Location
    Québec
    MS-Off Ver
    Excel 2021
    Posts
    2,081

    Re: Need dynamic macro to reformat data from one tab to another

    Do you want data to be erased from Sheet2 when macro is run?
    Pierre Leclerc
    _______________________________________________________

    If you like the help you got,
    Click on the STAR "Add reputation" icon at the bottom.

  3. #3
    Forum Contributor
    Join Date
    09-12-2012
    Location
    Michigan
    MS-Off Ver
    Excel 2007
    Posts
    127

    Re: Need dynamic macro to reformat data from one tab to another

    No, Sheet2 would originally be blank. Looking to keep source data on Sheet1.

    thanks

  4. #4
    Forum Expert p24leclerc's Avatar
    Join Date
    07-05-2010
    Location
    Québec
    MS-Off Ver
    Excel 2021
    Posts
    2,081

    Re: Need dynamic macro to reformat data from one tab to another

    Will column "Charges" be always at column S? This means there will always be only 15 PO columns.
    Is that right or when you say DYNAMIC you mean column CHARGES can be anywhere in the sheet?
    Can you make sure there will always be an empty column between the last PO and CHARGES columns?

  5. #5
    Forum Contributor
    Join Date
    09-12-2012
    Location
    Michigan
    MS-Off Ver
    Excel 2007
    Posts
    127

    Re: Need dynamic macro to reformat data from one tab to another

    No not necessarily, Charges will not all\way be column S. The there won't always only be 15 PO columns. That is one part of the file that will be dynamic, number of PO columns will always vary. The CHARGES column will always be to the right of the PO columns and yes there will always be a empty column between them.

    thanks

  6. #6
    Forum Expert p24leclerc's Avatar
    Join Date
    07-05-2010
    Location
    Québec
    MS-Off Ver
    Excel 2021
    Posts
    2,081

    Re: Need dynamic macro to reformat data from one tab to another

    Please try this macro. It seems to work with the data you supplied and with some test I also performed. I assumed that multiple POs where gathered on the left inthe columns like they are in your sample. If you have empty cells between PO in a row, the macro will not work. It is programmed to stop at the first empty colomn.
    Please Login or Register  to view this content.
    I also attached a workbook with the macro. Remark that the macro will erase any data on Sheet2 to make sure it starts from scratch.
    Attached Files Attached Files
    Last edited by p24leclerc; 01-25-2013 at 12:46 PM.

  7. #7
    Forum Contributor
    Join Date
    09-12-2012
    Location
    Michigan
    MS-Off Ver
    Excel 2007
    Posts
    127

    Re: Need dynamic macro to reformat data from one tab to another

    thanks, it works great. I just needed to remove one line,


    Range("PO_R").ClearContents

    and it was quick. great job.

    S4

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

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