+ Reply to Thread
Results 1 to 7 of 7

VBA Arrays macro performance

  1. #1
    Registered User
    Join Date
    04-02-2011
    Location
    Espoo
    MS-Off Ver
    Excel 2007
    Posts
    16

    VBA Arrays macro performance

    Hi,

    I have two sheets (Header & Item) in one file. Header has 25k and Item 50k rows. I'm looping through col B in Header and looking values in col B in Item and when we have a match then copying some values from Header-sheet to Item-sheet. I want this to be as fast as possible.

    I have two different macros to do this, both doing what I want and working basically fine. One uses arrays and the other one not. I read about arrays and thought that they should make this faster but the results are quite contrary. Array macro takes 336 seconds and the other one 42 seconds to accomplish.

    Is there something terribly wrong with my array macro or why is it so slow...? If there are any other comments or best practises concerning these macros, I would be glad to hear them. Thanks!

    Please Login or Register  to view this content.
    And the other macro as well:

    Please Login or Register  to view this content.

  2. #2
    Forum Expert nilem's Avatar
    Join Date
    10-22-2011
    Location
    Ufa, Russia
    MS-Off Ver
    2013
    Posts
    3,377

    Re: VBA Arrays macro performance

    Hi Sepi,
    look at this thread. Maybe it's would suit you

  3. #3
    Forum Guru JosephP's Avatar
    Join Date
    03-27-2012
    Location
    Ut
    MS-Off Ver
    2003/10
    Posts
    7,328

    Re: VBA Arrays macro performance

    worksheetfunction tends to be faster with ranges than arrays-I reckon that's probably why your array version is slower
    Josie

    if at first you don't succeed try doing it the way your wife told you to

  4. #4
    Forum Expert
    Join Date
    03-28-2012
    Location
    TBA
    MS-Off Ver
    Office 365
    Posts
    12,454

    Re: VBA Arrays macro performance

    Jay,
    I thought this line is

    Looping through a range while this line is
    Please Login or Register  to view this content.
    Please Login or Register  to view this content.
    is looping through the array.

    I am not sure what this line is

    Please Login or Register  to view this content.
    ,But it appears that the arrays are copied in to this line.

  5. #5
    Forum Guru JosephP's Avatar
    Join Date
    03-27-2012
    Location
    Ut
    MS-Off Ver
    2003/10
    Posts
    7,328

    Re: VBA Arrays macro performance

    how does that relate to what I said? I'm talking about
    Please Login or Register  to view this content.
    being faster than
    Please Login or Register  to view this content.

  6. #6
    Forum Guru JosephP's Avatar
    Join Date
    03-27-2012
    Location
    Ut
    MS-Off Ver
    2003/10
    Posts
    7,328

    Re: VBA Arrays macro performance

    if you want to test with a blank worksheet
    Please Login or Register  to view this content.

  7. #7
    Forum Expert
    Join Date
    03-28-2012
    Location
    TBA
    MS-Off Ver
    Office 365
    Posts
    12,454

    Re: VBA Arrays macro performance

    Jay,
    Okay, I see your point!

+ 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] looking for a way to increase macro performance
    By s4driver in forum Excel Programming / VBA / Macros
    Replies: 14
    Last Post: 06-27-2013, 01:48 PM
  2. Poor Macro Performance
    By ckm08 in forum Excel Programming / VBA / Macros
    Replies: 8
    Last Post: 01-07-2011, 04:36 AM
  3. Irregular Macro Performance
    By lostit in forum Excel Programming / VBA / Macros
    Replies: 26
    Last Post: 07-23-2009, 04:17 PM
  4. poor macro performance
    By [email protected] in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 08-16-2006, 09:05 PM
  5. Replies: 5
    Last Post: 07-05-2005, 05:05 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