+ Reply to Thread
Results 1 to 11 of 11

How to speed up this VBA Code?

  1. #1
    Forum Contributor
    Join Date
    08-29-2011
    Location
    Minnesota
    MS-Off Ver
    Office 365
    Posts
    163

    How to speed up this VBA Code?

    The below code took around 25 minutes to get to 10% complete on the first cycle, which if I did my math right, means I'm looking at more than 4 hours run time for it to get through it's first of two cycles. There are approximately 275,800 rows in this particular dataset, but the goal is to be able to use this code on both larger and smaller datasets.

    How can I speed this up?

    Please Login or Register  to view this content.
    Last edited by OpieWinston; 03-26-2021 at 10:25 AM.

  2. #2
    Administrator 6StringJazzer's Avatar
    Join Date
    01-27-2010
    Location
    Tysons Corner, VA, USA
    MS-Off Ver
    MS365 Family 64-bit
    Posts
    24,721

    Re: How to speed up this VBA Code?

    Please explain what you want this code to do.
    Jeff
    | | |會 |會 |會 |會 | |:| | |會 |會
    Read the rules
    Use code tags to [code]enclose your code![/code]

  3. #3
    Forum Contributor
    Join Date
    08-29-2011
    Location
    Minnesota
    MS-Off Ver
    Office 365
    Posts
    163

    Re: How to speed up this VBA Code?

    Identify medical claims that were denied under one treating provider, then later paid with a different treating provider listed.

  4. #4
    Valued Forum Contributor
    Join Date
    09-30-2018
    Location
    Vlaams Brabant Belgium
    MS-Off Ver
    365
    Posts
    456

    Re: How to speed up this VBA Code?

    would it be posible to setup a sample workbook with non personal information
    so we can do some testing?
    Please be as complete as possible in your asking so it may save use all the time to rework the solution because you didn't give all the requirements. If you have a layout in mind please work it out first so we can adapt our solution to it. Thanks.
    If you have been helped, maybe you could click the *

  5. #5
    Forum Contributor
    Join Date
    08-29-2011
    Location
    Minnesota
    MS-Off Ver
    Office 365
    Posts
    163

    Re: How to speed up this VBA Code?

    Not real sure how I'll accomplish that on such a large scale, but I'll see what I can do

  6. #6
    Valued Forum Contributor
    Join Date
    09-30-2018
    Location
    Vlaams Brabant Belgium
    MS-Off Ver
    365
    Posts
    456

    Re: How to speed up this VBA Code?

    no need to make a lot of data
    just copy 5 diferent lines
    remove personal info
    change name to name1 and pull down for as manny rows as you like

    what is in the "A1" rang in your sheet
    the macro point to that cell in every loop but its is not being updated so if that would be empty it would not run at all and if something is written in it it would endless loop
    i must be missing something

  7. #7
    Forum Contributor
    Join Date
    08-29-2011
    Location
    Minnesota
    MS-Off Ver
    Office 365
    Posts
    163

    Re: How to speed up this VBA Code?

    Ah shoot - only 5 or so lines? That I can do.

    The macro starts in A2, then goes to the next row down for every loop until there is no value in column A (first empty row).

    I'll be back with that sheet shortly

  8. #8
    Administrator 6StringJazzer's Avatar
    Join Date
    01-27-2010
    Location
    Tysons Corner, VA, USA
    MS-Off Ver
    MS365 Family 64-bit
    Posts
    24,721

    Re: How to speed up this VBA Code?

    Using ActiveCell is not especially efficient, although it's probably not your main problem. You have disabled screen updates so that helps.

    Please Login or Register  to view this content.
    I would iterate using the row number and then refer directly to the row number, rather than moving ActiveCell then extracting its row number.

    Please Login or Register  to view this content.
    Also, why do you make two complete passes through the data, rather than doing everything in one pass?

  9. #9
    Forum Contributor
    Join Date
    08-29-2011
    Location
    Minnesota
    MS-Off Ver
    Office 365
    Posts
    163

    Re: How to speed up this VBA Code?

    *FACEPALM*

    While putting together the sample sheet to upload, I realized my data was formatted as a table. Converted to range, ran the code again, and flew through the code in no time at all. A couple hours lost because I didn't convert to range...ugh...

    Thanks for your time and willingness to assist!

  10. #10
    Valued Forum Contributor
    Join Date
    09-30-2018
    Location
    Vlaams Brabant Belgium
    MS-Off Ver
    365
    Posts
    456

    Re: How to speed up this VBA Code?

    well i learned something today...
    didn't know that ActiveCell(2, 1).Select would change the selected cell

    i interpreted is as a Cells(2, 1).Select

    okay..

  11. #11
    Administrator 6StringJazzer's Avatar
    Join Date
    01-27-2010
    Location
    Tysons Corner, VA, USA
    MS-Off Ver
    MS365 Family 64-bit
    Posts
    24,721

    Re: How to speed up this VBA Code?

    Quote Originally Posted by Joske920 View Post
    I didn't know that ActiveCell(2, 1).Select would change the selected cell
    ActiveCell(2, 1) interprets ActiveCell as the upper-left cell of a range, and then allows offset addressing from it, even if it's outside the range. So if A1 is active, ActiveCell(2, 1) refers to A2. It is a kind of "tricky" programming similar to deliberately overflowing a buffer in C.

+ 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. i want to speed up the following code
    By dorabajji in forum Excel Programming / VBA / Macros
    Replies: 14
    Last Post: 06-15-2020, 06:28 AM
  2. Replies: 9
    Last Post: 05-21-2018, 04:34 PM
  3. Speed up code
    By relo in forum Excel Programming / VBA / Macros
    Replies: 9
    Last Post: 10-15-2015, 10:46 AM
  4. [SOLVED] VBA Delete Row Code - Need more efficient code to speed it up
    By matcapir in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 07-02-2015, 04:32 PM
  5. [SOLVED] Looking for help to speed up my code.
    By s4driver in forum Excel General
    Replies: 1
    Last Post: 03-25-2015, 12:32 PM
  6. [SOLVED] How to Speed Up the code ?
    By joh46k in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 04-03-2013, 09:42 PM
  7. Speed up code
    By MAButler in forum Excel Programming / VBA / Macros
    Replies: 9
    Last Post: 05-14-2011, 10:47 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