+ Reply to Thread
Results 1 to 8 of 8

Macro to Create separate sheet for each Unique Value in Col G and put SUMIFs Formula

  1. #1
    Forum Contributor
    Join Date
    06-03-2004
    Location
    India
    MS-Off Ver
    2013
    Posts
    205

    Macro to Create separate sheet for each Unique Value in Col G and put SUMIFs Formula

    Hello All,

    I am using Excel 2010 and have attached a sample of my problem

    I have two Sheets Data and Master

    Data Sheet has repeated Store Names in Col G

    I want the macro to copy the Master Sheet as per unique Store Names in Col G

    It should place the value from Data Sheet E5 to G2 and Sheet name in Cell L2 of each sheet
    Eg in the attached there would be total 21 Sheets i.e Master plus 20 Sheets for each Store

    Then I would need the SUMIFS Formula in Col F to Col J on all the Sheets

    Col F : =SUMIFS(Data!$K$5:$K$84,Data!$B$5:$B$84,Master!C5,Data!$F$5:$F$84,Master!$L$2)
    Col G : =SUMIFS(Data!$K$5:$K$84,Data!$B$5:$B$84,Master!C5,Data!$F$5:$F$84,"<>Reject")
    Col H : =SUMIFS(Data!$H$5:$H$84,Data!$B$5:$B$84,Master!C5,Data!$G$5:$G$84,Master!$L$2)
    Col I: =SUMIFS(Data!$I$5:$I$84,Data!$B$5:$B$84,Master!C5,Data!$G$5:$G$84,Master!$L$2)
    Col J: =SUMIFS(Data!$J$5:$J$84,Data!$B$5:$B$84,Master!C5,Data!$G$5:$G$84,Master!$L$2)

    Hope to get some help

    Thanks in advance

    Rashid
    Attached Files Attached Files
    Last edited by prkhan56; 06-29-2016 at 02:24 PM. 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: Macro to Create separate sheet for each Unique Value in Col G and put SUMIFs Formula

    Try this. The only two-step in the process is a small pivot table that gets the unique values for the store name. The names are "overlaid" with a named dynamic name. So you can change store names and the number of stores. Just make sure the pivot table refreshes.

    Otherwise I loop through the sheets and the actual sheet names to delete any sheets with those names so when I try to create them, I won't get an error.
    Attached Files Attached Files
    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
    Forum Moderator Leith Ross's Avatar
    Join Date
    01-15-2005
    Location
    San Francisco, Ca
    MS-Off Ver
    2000, 2003, & 2010
    Posts
    23,258

    Re: Macro to Create separate sheet for each Unique Value in Col G and put SUMIFs Formula

    Hello prkhan56,

    This VBA macro will create one sheet for each location using the "Master" as a template. The attached workbook has the macro added and a button on the "Master" to run it.

    Please Login or Register  to view this content.
    Attached Files Attached Files
    Sincerely,
    Leith Ross

    Remember To Do the Following....

    1. Use code tags. Place [CODE] before the first line of code and [/CODE] after the last line of code.
    2. Thank those who have helped you by clicking the Star below the post.
    3. Please mark your post [SOLVED] if it has been answered satisfactorily.


    Old Scottish Proverb...
    Luathaid gu deanamh maille! (Rushing causes delays!)

  4. #4
    Forum Contributor
    Join Date
    06-03-2004
    Location
    India
    MS-Off Ver
    2013
    Posts
    205

    Re: Macro to Create separate sheet for each Unique Value in Col G and put SUMIFs Formula

    Hello Leith,
    Your code works great.
    Just a small modification if you could do please
    If the copies of Master is already created then it creates a duplicate with the unique value in G5 of Data Sheet

    Is it possible to check and delete a sheet if it exists and then create a new copy.

    Thanks for your time and help
    Rashid

  5. #5
    Forum Contributor
    Join Date
    06-03-2004
    Location
    India
    MS-Off Ver
    2013
    Posts
    205

    Re: Macro to Create separate sheet for each Unique Value in Col G and put SUMIFs Formula

    Hello dflak,
    Your solution works great

    Thanks for your time and help

  6. #6
    Forum Moderator Leith Ross's Avatar
    Join Date
    01-15-2005
    Location
    San Francisco, Ca
    MS-Off Ver
    2000, 2003, & 2010
    Posts
    23,258

    Re: Macro to Create separate sheet for each Unique Value in Col G and put SUMIFs Formula

    Hello prkhan56,

    The macro has been changed to delete a unique sheet if it exists. replace the macro code in your workbook with the code below. The attached workbook has the change also.

    Please Login or Register  to view this content.
    Attached Files Attached Files

  7. #7
    Forum Contributor
    Join Date
    06-03-2004
    Location
    India
    MS-Off Ver
    2013
    Posts
    205

    Re: Macro to Create separate sheet for each Unique Value in Col G and put SUMIFs Formula

    Thanks Thanks and Thanks once again.
    Post marked Solved

  8. #8
    Forum Moderator Leith Ross's Avatar
    Join Date
    01-15-2005
    Location
    San Francisco, Ca
    MS-Off Ver
    2000, 2003, & 2010
    Posts
    23,258

    Re: Macro to Create separate sheet for each Unique Value in Col G and put SUMIFs Formula

    Hello prkhan56,

    You're welcome.

+ 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. automate SUMIFS formula in vba code for UNIQUE DATA
    By JEAN1972 in forum Excel General
    Replies: 1
    Last Post: 02-08-2016, 05:29 PM
  2. [SOLVED] Help request to create a unique id by macro or formula
    By mso3 in forum Excel Formulas & Functions
    Replies: 4
    Last Post: 10-24-2015, 08:00 AM
  3. [SOLVED] Create Macro to Search for specific word on separate sheet
    By papinj2004 in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 06-24-2014, 03:36 PM
  4. [SOLVED] VBA / Macro help needed to create separate sheets from Master sheet by year
    By krjoshi in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 09-09-2013, 08:34 AM
  5. Macro to create unique list on new work sheet
    By strud in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 08-13-2013, 08:29 AM
  6. [SOLVED] Macro To Create New Sheet (and rename it) based on unique values in column
    By himynameisiain in forum Excel Programming / VBA / Macros
    Replies: 14
    Last Post: 07-31-2013, 08:59 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