+ Reply to Thread
Results 1 to 3 of 3

General help simplifying my super slow VB code PLEASE :-D

  1. #1
    Registered User
    Join Date
    05-29-2013
    Location
    Brighton, England
    MS-Off Ver
    Excel 2007
    Posts
    4

    General help simplifying my super slow VB code PLEASE :-D

    Hi all, i'm a self taught fan of excel & vb but i'm still very much a novice when it comes to using some of the more advanced functions and my main problem at the moment seems to be that my code always ends up being very long winded and could very likely be simplified by quite some degree. This is probably as I still don't quite know what i'm doing :-S. I find that i'm often compelled to using select and activate functions which i'm aware is bad practice and can considerably slows things down.

    I've created a macro that basically searches a relatively large number of worksheets (approx 50) for a user defined unique number and then replaces another value (the price) in the same row as the unique number. This can be repeated up to 8 times depending on how many unique numbers are being searched for! HOWEVER...this is taking a HUGE amount of time to complete. Between 30 seconds for 1 unique number search and 200 seconds for all 8. Although this means not having to scroll through sheets and sheets to locate these individually it still takes about the same amount of time which defeats the object.

    I'd like to see firstly if somebody could please please please help me simplify the code which might speed things up and secondly if anyone could explain to me why when I hit the Escape key while the macro is running it completes the function in super lightning fast time (we're talking about a second) instead of the usual 30-200 second delay?! I just don't understand :-(

    My code:
    Please Login or Register  to view this content.
    Last edited by blackcat_78uk; 04-30-2015 at 04:43 PM. Reason: added code tags

  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: General help simplifying my super slow VB code PLEASE :-D

    Quote Originally Posted by blackcat_78uk View Post
    Sorry WhizBang is that what you mean?
    Yes. However, in the future please edit your original post instead of re-posting all your code. I have cleaned things up for you because you are new.

    Rule 3 of our Forum RULES. Use code tags around code.

    Posting code between [CODE]Please [url=https://www.excelforum.com/login.php]Login or Register [/url] to view this content.[/CODE] tags makes your code much easier to read and copy for testing, it also maintains VBA formatting.

    Highlight your code and click the # icon at the top of your post window. More information about these and other tags can be found here

    I am encountering an error on the forum that will not allow me to edit the original post. Please edit your original post to add code tags.
    Last edited by 6StringJazzer; 04-30-2015 at 04:10 PM. Reason: in blue
    Jeff
    | | |會 |會 |會 |會 | |:| | |會 |會
    Read the rules
    Use code tags to [code]enclose your code![/code]

  3. #3
    Forum Expert skywriter's Avatar
    Join Date
    06-09-2014
    Location
    USA
    MS-Off Ver
    2016
    Posts
    2,760

    Re: General help simplifying my super slow VB code PLEASE :-D

    Here's a few suggestions. Always define a sheet and a range and then you don't have to select them.

    Here's some code to put at the top, you can probably figure out where.

    Please Login or Register  to view this content.
    Then down where you do the active cell offset stuff put this.
    Please Login or Register  to view this content.
    Another example would be writing this code:

    Please Login or Register  to view this content.
    Like this:

    Please Login or Register  to view this content.
    EDIT: I changed the first code I posted, I left out a couple of lines.
    Last edited by skywriter; 04-30-2015 at 05:31 PM.
    Click the * Add Reputation button in the lower left hand corner of this post to say thanks.

    Don't forget to mark this thread SOLVED by going to the "Thread Tools" drop down list above your first post and choosing solved.

+ 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] Need help with an excel file that is super slow and crashes a lot.
    By regorih in forum Excel General
    Replies: 6
    Last Post: 01-14-2014, 07:23 PM
  2. Can anyone help with simplifying this super long Excel IF statement?
    By YPerez in forum Excel Formulas & Functions
    Replies: 1
    Last Post: 08-21-2013, 05:35 PM
  3. 2003 code runs super slow in 2010
    By emanresu65 in forum Excel Programming / VBA / Macros
    Replies: 20
    Last Post: 01-04-2013, 05:25 PM
  4. Tons of Arrays = Super Slow Calculating
    By danmarsh in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 08-23-2012, 01:52 PM
  5. speeding up code that is super slow
    By cabinetguy in forum Excel Programming / VBA / Macros
    Replies: 28
    Last Post: 05-19-2011, 12:24 PM

Tags for this Thread

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