+ Reply to Thread
Results 1 to 11 of 11

Taking new data from one list and adding it to another list via VBA

  1. #1
    Registered User
    Join Date
    01-30-2013
    Location
    Long Island NY
    MS-Off Ver
    Office 365
    Posts
    81

    Taking new data from one list and adding it to another list via VBA

    I have 2 sheets: "MasterInventory" and "InventoryFeed". "MasterInventory", is my full list of all the item I sell on Amazon.com. "InventoryFeed" is populated when I download an update from amazon and paste the data into it. Each list has about 30 columns and each list uses identical headings in the top row. The third column in each sheet is for the product's SKU.

    What I'd like to do is loop through each row in the "inventoryFeed" sheet, assign it's sku (the value in column 3) to a variable, and then copy the entire Row. Then I'd like to switch to the "MasterInventory" sheet, and look in column C for the identical SKU. If it is found, I'd like to overwrite the entire line by pasting in the data that was copied earlier. If the SKU is not discovered, I'd like to paste the information into the next blank row in the "masterInventory" sheet.

    After the whole thing is looped through, I'd like to sort the MasterInventory Sheet from A to Z by the product's SKU.

    Any help would really be appreciated!

  2. #2
    Forum Moderator alansidman's Avatar
    Join Date
    02-02-2010
    Location
    Steamboat Springs, CO
    MS-Off Ver
    MS Office 365 insider Version 2506 Win 11
    Posts
    24,764

    Re: Taking new data from one list and adding it to another list via VBA

    It would be very helpful if you were to post (upload) a sample spreadsheet. It does not need a lot of data, but enough so that any code written can be tested adequately.

    Attach a sample workbook. Make sure there is just enough data to make it clear what is needed. 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 demonstrated, mock them up manually if needed. Remember to desensitize the data.

    Click on GO ADVANCED and use the paperclip icon to open the upload window.

    View Pic
    Alan עַם יִשְׂרָאֵל חַי


    Change an Ugly Report with Power Query
    Database Normalization
    Complete Guide to Power Query
    Man's Mind Stretched to New Dimensions Never Returns to Its Original Form

  3. #3
    Forum Expert Olly's Avatar
    Join Date
    09-10-2013
    Location
    Darlington, UK
    MS-Off Ver
    Excel 2016, 2019, 365
    Posts
    6,284

    Re: Taking new data from one list and adding it to another list via VBA

    Easier to help if you can attach an example worksheet. Show us how your data is laid out, and what your thoughts / progress is so far.
    let Source = #table({"Question","Thread", "User"},{{"Answered","Mark Solved", "Add Reputation"}}) in Source

    If I give you Power Query (Get & Transform Data) code, and you don't know what to do with it, then CLICK HERE

    Walking the tightrope between genius and eejit...

  4. #4
    Registered User
    Join Date
    01-30-2013
    Location
    Long Island NY
    MS-Off Ver
    Office 365
    Posts
    81

    Re: Taking new data from one list and adding it to another list via VBA

    VBA Forum Sample.xlsm

    OK, I attached a sample workbook. The full workbook has many more sheets, but all that's necessary here are these two.

    In plain English, here's what I'm after...

    I sell stuff on Amazon.com. I want to use the data that they store on their servers (item weight, size, category, fulfillment cost etc.) to analyze what's profitable and what's not.

    In the attached sample, the sheet "FBA Fee Feed" is what I get off Amazon's site. I basically download it and it opens automatically in a new excel sheet. I then copy and paste it into the "FbaFeeFeed" sheet of my workbook.

    I could have simply used Amazon's data alone and not dealt with creating a second sheet (here named: "Full Inventory"), but Amazon only provides data for products that are actually in stock in their fulfillment center. Once any of my products sells out, it will no longer be in their data feed, which doesn't do me much good.

    So the whole idea is to establish a worksheet that has a full listing of that I sell, whether it's in stock or not.

    I mentioned in my initial post that when the macro finds a product from the data feed that is already in the "Full Inventory" sheet, that it should overwrite the entire line. The reason for this is sometimes there can be slight changes in one or two cells, so just overwriting the existing data keeps everything up to date.

    One last thing... I mentioned in the original post that I want to compare "SKU's" from each sheet. I used that term to avoid confusion, but now that I've uploaded that sample workbook, I'll be more specific. The actual item I want to compare is called the "ASIN", which is Amazon's unique designation for each product that's on the site. Regardless of what's it's called, the piece of data that is used to compare one sheet against the other is on column "C" in both work sheets.

  5. #5
    Forum Expert Olly's Avatar
    Join Date
    09-10-2013
    Location
    Darlington, UK
    MS-Off Ver
    Excel 2016, 2019, 365
    Posts
    6,284

    Re: Taking new data from one list and adding it to another list via VBA

    Try something like this:
    Please Login or Register  to view this content.
    It loops through each row of FbaFeeFeed, and checks to find a match in Full Inventory, based on the value in column C. The entire source row is copied, to either the matching row, or the next blank row, of FullInventory.

  6. #6
    Registered User
    Join Date
    01-30-2013
    Location
    Long Island NY
    MS-Off Ver
    Office 365
    Posts
    81

    Re: Taking new data from one list and adding it to another list via VBA

    Wow! I just discovered a new definition of "awesome". I think you were able to solve the problem faster than I could explain the problem!

    Could I ask you to do just minor tweak?

    After the looping is done, could you sort the "Full Inventory" sheet by my SKU (which appears in column A) from a to z?

    Thanks !

  7. #7
    Forum Expert Olly's Avatar
    Join Date
    09-10-2013
    Location
    Darlington, UK
    MS-Off Ver
    Excel 2016, 2019, 365
    Posts
    6,284

    Re: Taking new data from one list and adding it to another list via VBA

    Sure - add this line just before End Sub:
    Please Login or Register  to view this content.
    And thanks for the feedback, glad it helps

  8. #8
    Registered User
    Join Date
    01-30-2013
    Location
    Long Island NY
    MS-Off Ver
    Office 365
    Posts
    81

    Re: Taking new data from one list and adding it to another list via VBA

    Sweet! Reputation points are on their way!

    Thanks again!

  9. #9
    Registered User
    Join Date
    01-30-2013
    Location
    Long Island NY
    MS-Off Ver
    Office 365
    Posts
    81

    Re: Taking new data from one list and adding it to another list via VBA

    I hate to be seen as going to the well a second time, but I wonder if you or someone else could add just one more tweak to the code.

    Amazon doesn't especially like quotation marks in seller's SKU's, so they will always take a SKU like this:

    Furn Glide - Felt 1 1/8" x 16

    and turn it into this: Furn Glide - Felt 1 1/8" x 16

    I've been handling this up till now with a simple "substitute" formula, but it would be much more elegant if the conversion were done via VBA.

    How can I accomplish this while the code is looping through?

  10. #10
    Forum Expert Olly's Avatar
    Join Date
    09-10-2013
    Location
    Darlington, UK
    MS-Off Ver
    Excel 2016, 2019, 365
    Posts
    6,284

    Re: Taking new data from one list and adding it to another list via VBA

    Added to your code:
    Please Login or Register  to view this content.
    I've also added lines to disable screenupdating while the code runs, to speed it up.
    See additions highlighted red.
    Last edited by Olly; 02-11-2014 at 04:20 PM.

  11. #11
    Registered User
    Join Date
    01-30-2013
    Location
    Long Island NY
    MS-Off Ver
    Office 365
    Posts
    81

    Re: Taking new data from one list and adding it to another list via VBA

    Worked like a charm Olly. Thanks!

    One quick observation...

    I noticed when stepping through the code that it searches every cell on the sheet for the weird characters, while they only appear in Column A. Is it possible to just have it do the replace in that column? This would speed things up quite a lot I think.

+ 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: 0
    Last Post: 01-09-2013, 11:44 AM
  2. [SOLVED] Taking a list of tasks and a list of subtasks and creating a new list with groupings
    By kknb0800 in forum Excel Programming / VBA / Macros
    Replies: 8
    Last Post: 11-06-2012, 12:16 PM
  3. Replies: 3
    Last Post: 07-20-2012, 09:52 AM
  4. Taking a top 50 list into averages
    By IndieIPA in forum Excel General
    Replies: 6
    Last Post: 03-06-2012, 11:23 AM
  5. [SOLVED] mail merge- & data source - only taking 1st name in the list
    By harriet in forum Excel General
    Replies: 6
    Last Post: 02-20-2005, 10:06 PM

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