+ Reply to Thread
Results 1 to 7 of 7

VBA For loop, optimize speed and performance

  1. #1
    Registered User
    Join Date
    12-06-2013
    Location
    Swe
    MS-Off Ver
    Excel 2007
    Posts
    26

    VBA For loop, optimize speed and performance

    Hi, how can I optimize this Macro? I have a lot of these and the sheets they are supposed to read from can be up to 40 columns wide and
    at this time 10.000 rows. I would though like the Macro to able to read more, like 20-50k rows. I think it can but it will be quite slow.
    Haven't tested it yet.

    Also I don't really get if the Macro checks all rows but doesn't print. (I think it does).
    If so can I make it not to, to improve performance?

    Please Login or Register  to view this content.
    Any help would be greatly appreciated.

    /BC

  2. #2
    Forum Guru Norie's Avatar
    Join Date
    02-02-2005
    Location
    Stirling, Scotland
    MS-Off Ver
    Microsoft Office 365
    Posts
    19,643

    Re: VBA For loop, optimize speed and performance

    What separator are you using?
    If posting code please use code tags, see here.

  3. #3
    Registered User
    Join Date
    12-06-2013
    Location
    Swe
    MS-Off Ver
    Excel 2007
    Posts
    26

    Re: VBA For loop, optimize speed and performance

    Vertical Bar |, why? It cant really make any difference can it? Its used in the upload function to Database. I have a Drop down in one of the sheets where you can select which Separator you want but its vertical bar atm.

  4. #4
    Forum Guru Norie's Avatar
    Join Date
    02-02-2005
    Location
    Stirling, Scotland
    MS-Off Ver
    Microsoft Office 365
    Posts
    19,643

    Re: VBA For loop, optimize speed and performance

    I was wondering if it would be possible to save as a delimited file but that's seems unlikely.

    One thing you could do is use Join to concatenate the values from each row into a delimited list.
    Please Login or Register  to view this content.
    You could also considered putting all the data from the UsedRange in an array and work with that, it's quicker to work with data in memory than accessing it on a worksheet.

  5. #5
    Registered User
    Join Date
    12-06-2013
    Location
    Swe
    MS-Off Ver
    Excel 2007
    Posts
    26

    Re: VBA For loop, optimize speed and performance

    Ok, thanks. Can you please give any hinters on how to do that?

  6. #6
    Forum Guru Norie's Avatar
    Join Date
    02-02-2005
    Location
    Stirling, Scotland
    MS-Off Ver
    Microsoft Office 365
    Posts
    19,643

    Re: VBA For loop, optimize speed and performance

    The code I posted does the first thing I suggested, did you try it?

    Here's code for the second suggestion.
    Please Login or Register  to view this content.

  7. #7
    Registered User
    Join Date
    12-06-2013
    Location
    Swe
    MS-Off Ver
    Excel 2007
    Posts
    26

    Re: VBA For loop, optimize speed and performance

    Oh sorry didnt look. =/ Thanks i will try and come back.

+ 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. Is there any way to optimize this FOR loop?
    By lxsscott in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 10-23-2013, 03:50 PM
  2. how to optimize finding matching values macro speed
    By missy22 in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 09-25-2013, 10:48 AM
  3. [SOLVED] Combine VBA Modules to Speed Performance???
    By Jester0001 in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 01-30-2013, 06:56 PM
  4. Increase performance speed by removing INDIRECT functions
    By pepperjoe in forum Excel General
    Replies: 1
    Last Post: 05-19-2011, 10:22 AM
  5. Replies: 1
    Last Post: 04-02-2011, 06:39 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