+ Reply to Thread
Results 1 to 4 of 4

Auto copy data based on multiple criteria from one sheet to a specific location in another

  1. #1
    Registered User
    Join Date
    05-16-2016
    Location
    Orange County, CA
    MS-Off Ver
    Excel 2010
    Posts
    17

    Auto copy data based on multiple criteria from one sheet to a specific location in another

    Hi Excel Experts, I've been researching this for quite a while to no avail.

    I've looked for applicable code, but I'm new to VBA and having difficulty piecing together code that will work. .

    I have three sheets in one workbook. The main sheet, "SA" has a summary of all soda sales by week. I need a formula or VB code smart enough to search sheets "SD" and "SD2" and return any new unique records into the corresponding section in sheet "SA".

    In this example since Costco and Walmart are now receiving Vanilla Soda, I'd like the new product, Vanilla Soda, to be added as a line item under Costco and Walmart sections respectively on sheet "SA". I'll probably just use a sumifs + sumproduct + indirect formula to the weekly total of [cases delivered "TOTAL CASES" from sheets "SD" and "SD2".

    I don't need the entire row returned. I only need the first four fields on sheet "SA".
    "SD" and "SD2" will each have thousands of records refreshed daily from other master spreadsheets.
    I'm not sure how many records will need to e transferred from those sheets to sheet "SA" daily.
    I've been asked not to use a pivot table.
    I don't know if it matters, but I'll be creating a dashboard based on the "SA" sheet.
    I hope I've explained this well.
    Any help you can offer is greatly appreciated.
    Attached Files Attached Files
    Last edited by onepoefan; 05-16-2016 at 07:04 PM.

  2. #2
    Forum Guru xladept's Avatar
    Join Date
    04-14-2012
    Location
    Pasadena, California
    MS-Off Ver
    Excel 2003,2010
    Posts
    12,378

    Re: Auto copy data based on multiple criteria from one sheet to a specific location in ano

    "Nevermore" for a macro?

    Else:

    Attach a sample workbook. Make sure there is just enough data to demonstrate your need. Include a BEFORE sheet and an AFTER sheet in the workbook if needed to show the process you're trying to complete or automate. Make sure your desired results are shown, mock them up manually if necessary.

    Remember to desensitize the data.

    Click on GO ADVANCED and then scroll down to Manage Attachments to open the upload window (or use the paperclip icon).
    If I've helped you, please consider adding to my reputation - just click on the liitle star at the left.

    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~(Pride has no aftertaste.)

    You can't do one thing. XLAdept

    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~aka Orrin

  3. #3
    Registered User
    Join Date
    05-16-2016
    Location
    Orange County, CA
    MS-Off Ver
    Excel 2010
    Posts
    17

    Re: Auto copy data based on multiple criteria from one sheet to a specific location in ano

    Thank you for your guidance. I'm attaching a revised file and a better explanation of the process and the expected results.

    The data in SodaSales is mock data, but the structure of the workbook is identical to the workbook I'm using. I'll refer to my actual workbook as workbook1.

    I'm using Excel 2010 MS Office 2010 Professional on a Windows platform.

    I'm open to whatever solution will be most efficient.

    My Process:

    In SodaSales.xls the SA tab will ultimately be used for reporting purposes, a dashboard,etc.

    In workbook1 the SA tab pulls data from two other tabs, SD and SD2. Both SD and SD2 are linked via data connection to their corresponding master files on the network, and I'll have the connection set to refresh when the file opens. I wanted to combine the two tabs into one, but my IT guy said there will be too many records to combine the two tabs. Since the existing records are not flagged, I don't know exactly how many new records are added each day/week/month.However, I did a manual sort on the two master files.
    Here's what I see:
    Master file one has 36,368 records so far this year. In this file there are 16,200 records for Jan and 2,300 records for February. Master file two only has about 12,233 records so far this year.

    In workbook1 I copied the existing records from SD to SD2 and removed the duplicates. Then I inserted subtotals to get the weekly total by customer. The format of the SA Before tab looks the same in SodaSales. It just has much less records.

    Expected results:
    SA Before lists the records as of the end of the forth week of January. SA After has the new records for the last week of January pulled from SD and SD2. In SA After we can see that Costco has received a shipment of Vanilla Soda which is a brand new product, and they have also received a shipment of Raspberry Soda which some stores were already purchasing.The same is true for Target.

    My dilemma is how do I get Excel to automatically copy the WAREHOUSE, SHIPTO_NUMBER, SHIPTO_NAME and PRODUCT_NUMBER fields for these new records as they updated into the SD and SD2 tabs?

    Other fields on the SA tab:
    The product description will be pulled from another tab using VLOOKUP because the descriptions in the master files are confusing.
    The CASE_SIZE and SALESPERSON fields will be populated manually.
    *Thanks to John* The total number cases per week listed in columns I through AF will be calculated using this formula:
    =SUMPRODUCT(SUMIFS(INDIRECT("'"&{"SD";"SD2"}&"'!F2:F100"),
    INDIRECT("'"&{"SD";"SD2"}&"'!C2:C100"),$D7,
    INDIRECT("'"&{"SD";"SD2"}&"'!A2:A100"),$B7,
    INDIRECT("'"&{"SD";"SD2"}&"'!B2:B100"),$C7,
    INDIRECT("'"&{"SD";"SD2"}&"'!E2:E100"),$A7,
    INDIRECT("'"&{"SD";"SD2"}&"'!D2:D100"),$E7&"*",
    INDIRECT("'"&{"SD";"SD2"}&"'!g2:g100"),YEAR(I$6)&"*"&I$5))

    I have seen code that copys records, but I'm not familiar enough with VB to piece it together for this scenario or savvy enough to know if there's a better solution. I'm eager to learn and very appreciative of any help you have to offer!
    Attached Files Attached Files

  4. #4
    Forum Expert
    Join Date
    05-05-2015
    Location
    UK
    MS-Off Ver
    Microsoft Excel for Microsoft 365 MSO (Version 2402 Build 16.0.17328.20068) 64-bit
    Posts
    31,182

    Re: Auto copy data based on multiple criteria from one sheet to a specific location in ano

    @xladept (and others): I have posted a "simple" potential VBA solution which copies data from the SD/SD2 worksheets to the SA worksheet on the " Formulas & Functions" forum based on the earlier information given by "Onepoefan".


    http://www.excelforum.com/excel-form...n-another.html
    Last edited by JohnTopley; 05-17-2016 at 05:18 PM.

+ 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. Replies: 17
    Last Post: 05-23-2016, 11:04 PM
  2. Replies: 2
    Last Post: 01-23-2016, 01:16 PM
  3. [SOLVED] Copy and paste specific cell to another sheet based on multiple criteria
    By impresxy in forum Excel Programming / VBA / Macros
    Replies: 8
    Last Post: 11-09-2015, 07:11 AM
  4. [SOLVED] Copy Data from one Sheet to another based on multiple criteria
    By ParisG in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 01-23-2014, 02:53 AM
  5. Copy data from multiple sheet based on a criteria
    By nishan.biswas.buet in forum Excel Programming / VBA / Macros
    Replies: 9
    Last Post: 01-22-2014, 10:48 AM
  6. Need VBA to auto copy data from one sheet to specific on based of Staus
    By nadeemjadoon in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 01-04-2013, 12:25 PM
  7. [SOLVED] Copy and paste data from sheet 2 to sheet 1 based on specific criteria on sheet 1
    By VBADUD in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 12-05-2012, 04:18 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