+ Reply to Thread
Results 1 to 14 of 14

Looping through 50k rows of sales data

  1. #1
    Registered User
    Join Date
    07-04-2012
    Location
    Sweden
    MS-Off Ver
    Excel 2010
    Posts
    15

    Looping through 50k rows of sales data

    Hi all. I'm a beginner so I guess this is a beginner question However...

    I have made a Macro for a sales rapport, as I want to merge some number from the article list into the sales list. I would be in great help for some feedback.

    To begin with, I have one sheet which is a sales reports file with 50000 rows, and I have one sheet with is an article list on 500 rows. The common denominator is the SKU. (Every sales order row has a SKU and every article list row has a SKU.)

    Now I would like to add some article info (whether it is a central warehouse product or not) into the sales sheet in order to make stats. Thus, I made a new column in the sales sheet and made a macro.

    Basically what the macro does is to loop through all sales 50000 rows, and for each row it checkes for a SKU-match in the article row (loops up to 500 until match). If the CWP-kolumn is 1 in the article sheet, I set the new CWP-column in the sales sheet to 1 as well. If not, I set it to 0. (And if we get no SKU-match at all, it should be 2.)

    I have two questions:
    1. In this solution, I can only run 5000 lines at a time. Is there a setting to that I could run all the rows in one click? I understnad it's up to 50000x500 rows to go through, but could I make the process to run in a slower pace or something in order not to hang up.
    2. Is there a better way of doing this?

    Thanks in advance

    Slightly simplified, this is my code:

    Please Login or Register  to view this content.

  2. #2
    Valued Forum Contributor
    Join Date
    05-11-2013
    Location
    Wales
    MS-Off Ver
    Excel 2010
    Posts
    586

    Re: Looping through 50k rows of sales data

    Hi erison,

    Can you please attach a copy of your xlsx file.
    It it's larger than 1Mb can you provide "cut-down" version, i.e. 1000 rows instead of 50000 rows.

    To attach a file to your post,
    • be sure to desensitize the data
    • click “Go Advanced” (next to Post Quick Reply – bottom right),
    • scroll down until you see “Manage Attachments”, click that,
    • click “Browse”.
    • select your file(s)
    • click “Upload”
    • click “Close window”
    • click “Submit Reply”

    Regards

    peterrc

  3. #3
    Registered User
    Join Date
    07-04-2012
    Location
    Sweden
    MS-Off Ver
    Excel 2010
    Posts
    15

    Re: Looping through 50k rows of sales data

    Hi.

    I have now attached a file with very little data (as this is quite sensitive) but with the design of the file.

    Thanks for pushing me through this, obviously my original code didn't exactly doing what I wanted. I changed the position of one row and now it works (I think):

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

  4. #4
    Valued Forum Contributor
    Join Date
    05-11-2013
    Location
    Wales
    MS-Off Ver
    Excel 2010
    Posts
    586

    Re: Looping through 50k rows of sales data

    Hi erison,

    In your original post you stated 50,000 rows.
    The file you attached has 9 rows plus headers, mainly "x" and single numbers in just 2 coulums, A and C.
    Obviously there is nothing to work with.
    Have you attached the wrong file.

    Regards

    peterrc

    Edit 1
    There are 19 numbers in column L on the Sales sheet but still not enough data to work with.
    Last edited by peterrc; 10-13-2017 at 11:28 AM.

  5. #5
    Registered User
    Join Date
    07-04-2012
    Location
    Sweden
    MS-Off Ver
    Excel 2010
    Posts
    15

    Re: Looping through 50k rows of sales data

    Hi. No this is just a copy in order to show the structure while not revealing the original data. Would it help a lot to add more sample data into it?

  6. #6
    Valued Forum Contributor
    Join Date
    05-11-2013
    Location
    Wales
    MS-Off Ver
    Excel 2010
    Posts
    586

    Re: Looping through 50k rows of sales data

    Hi erison,

    Yes, it would help, together with a "mock-up" of what you want the Articles sheet to look like when "finished".

    Regards

    peterrc

  7. #7
    Registered User
    Join Date
    07-04-2012
    Location
    Sweden
    MS-Off Ver
    Excel 2010
    Posts
    15

    Re: Looping through 50k rows of sales data

    Ok, I will look for a way to generate sample data then and come back

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

    Re: Looping through 50k rows of sales data

    Try this:

    Please Login or Register  to view this content.
    Last edited by xladept; 10-13-2017 at 01:31 PM.
    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

  9. #9
    Registered User
    Join Date
    07-04-2012
    Location
    Sweden
    MS-Off Ver
    Excel 2010
    Posts
    15

    Re: Looping through 50k rows of sales data

    Great, thank you XLAdept. I am not familiar with CreateObject, but if I read the code correcly this is what happens: In the first loop, all SKUs from the articles are put in a dictionary. In the second loop, .Exists checks if the actual Sales SKU is in the dictionary and sets the number to one or two.

    This code is definitely prettier, but does it make fewer operations than mine? (I don't try to be critical, just curious.) Or does something else makes it faster? (Maybe going through a dictionary is faster than looping through cells?)

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

    Re: Looping through 50k rows of sales data

    It's faster because the sales sheet is transformed into a worksheet array making each operation occur in nanoseconds rather than microseconds!
    Last edited by xladept; 10-16-2017 at 12:35 PM.

  11. #11
    Registered User
    Join Date
    07-04-2012
    Location
    Sweden
    MS-Off Ver
    Excel 2010
    Posts
    15

    Re: Looping through 50k rows of sales data

    Ah ok, I see. Thanks

  12. #12
    Registered User
    Join Date
    07-04-2012
    Location
    Sweden
    MS-Off Ver
    Excel 2010
    Posts
    15

    Re: Looping through 50k rows of sales data

    Does anyone know the answer of my question no1? Is there a way to make excel run in more of a marathon tempo than 100m tempo in order to complete very heavy operations (while doing it over more time). Thanks

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

    Re: Looping through 50k rows of sales data

    Is this still too fast?

    Please Login or Register  to view this content.

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

    Re: Looping through 50k rows of sales data

    You're welcome and thanks for the rep!

+ 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] Vlookup to pull in sales data based on the month sales begins
    By adam_d_john in forum Excel Formulas & Functions
    Replies: 17
    Last Post: 06-12-2017, 05:07 PM
  2. [SOLVED] Looping through rows of data to find a certain city
    By bilich in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 01-10-2017, 12:27 PM
  3. Looping through rows to consolidate mismatched data?
    By DouglasMacArthur in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 05-26-2016, 02:31 PM
  4. [SOLVED] Making Daily Sales Planner recognize which month and which week to pull sales data from
    By Topher53180 in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 07-30-2014, 10:33 AM
  5. Replies: 7
    Last Post: 07-23-2013, 07:56 AM
  6. Useform which search the data of Primary sales and i can enter secondary sales data.
    By bipin_04 in forum Excel Programming / VBA / Macros
    Replies: 11
    Last Post: 05-31-2013, 11:29 AM
  7. Replies: 4
    Last Post: 03-27-2013, 05:56 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