+ Reply to Thread
Results 1 to 9 of 9

Make VBA code faster

  1. #1
    Forum Contributor
    Join Date
    07-10-2013
    Location
    Veendam
    MS-Off Ver
    Excel 2007
    Posts
    100

    Make VBA code faster

    Hi all,

    It Is also possible to speed up this code? (see example)

    At the moment, the running time is about 20 minutes.

    I have a small example added.

    Greetings,

    Danielle
    Attached Files Attached Files

  2. #2
    Valued Forum Contributor
    Join Date
    10-26-2008
    Location
    Birmingham, UK
    MS-Off Ver
    All versions up to 2010
    Posts
    1,025

    Re: Make VBA code faster

    Hi Danielle
    I have run the code on the Macro worksheet as pere your sample and it took less than a second to run. Is this the same code you are having issues with?
    Tony

  3. #3
    Forum Contributor
    Join Date
    07-10-2013
    Location
    Veendam
    MS-Off Ver
    Excel 2007
    Posts
    100

    Re: Make VBA code faster

    Hi Tony,

    The code in this example is very quickly. My original file had over the 40000 rows and is 3 MB.

    Right now the code is running about 20 minutes (in the original file).

    Maybe there is a solution to make the code slightly faster?

    Greetings,

    Danielle

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

    Re: Make VBA code faster

    You have over 20 codes. Which code are you referring to?

  5. #5
    Forum Contributor
    Join Date
    07-10-2013
    Location
    Veendam
    MS-Off Ver
    Excel 2007
    Posts
    100

    Re: Make VBA code faster

    It is the code under the button in the sheet "macro". The name of the code is "KopieuitDownload" and it is in module 11.

    Greetings,

    Danielle

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

    Re: Make VBA code faster

    I do not know what other could execute it faster than filter.
    I suspect the issue is not with the code but with the data type you have.
    These data may be downloaded from an Accounting system, such as SAP. These data have lots of unseen- dirty data type, such as unprintable characters.
    You can get rid of these characters by copying the data and paste them as VALUES ONLY. This will remove most of these dirty data.
    You can also run trim and clean functions.
    So, copy the data and convert them in to VALUES ONLY, then delete the original data from your book. You will see difference in speed.

  7. #7
    Valued Forum Contributor
    Join Date
    10-26-2008
    Location
    Birmingham, UK
    MS-Off Ver
    All versions up to 2010
    Posts
    1,025

    Re: Make VBA code faster

    Hi Danielle
    I have had a look at your sample document based on AB33s advice and I can find no issues with white spaces etc so this is not your issue. I have also looked at your code and a small section confuses me a little if I am understanding it correctly:
    With Sheets("TariefDisplay").Columns(17)
    Set r = .Find("PH")
    If Not r Is Nothing Then
    adr = r.Address
    Do
    You are searching for "PH" in column 17 and returning the address of the cell when it is found in the variable named adr. The cell address it is returning is Q2. However this cell is empty so I am not sure why it is finding this cell. Can you expand on what the macro is supposed to do?
    Tony

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

    Re: Make VBA code faster

    Q2 isn't empty-it has a white font applied ;-)

    you could remove the .autofilter line as there isn't really a need to clear the filter within the loop
    Josie

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

  9. #9
    Valued Forum Contributor
    Join Date
    10-26-2008
    Location
    Birmingham, UK
    MS-Off Ver
    All versions up to 2010
    Posts
    1,025

    Re: Make VBA code faster

    Duplicate entry.
    Last edited by ARGK; 10-28-2013 at 09:03 AM. Reason: Duplicate entry.

+ 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. Make the below code work faster!!!
    By devpp in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 09-04-2013, 06:13 AM
  2. [SOLVED] Ways to make my code run faster
    By JazzyBear in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 03-03-2013, 03:59 PM
  3. [SOLVED] Make code run faster
    By ozhunter in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 02-20-2013, 04:26 AM
  4. Helps to make code faster
    By a_driga in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 04-26-2012, 12:25 AM
  5. Is it possible to get rid of this loop to make the code faster?
    By mhw1129 in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 04-09-2011, 09:03 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