+ Reply to Thread
Results 1 to 4 of 4

Code works, but takes far too long

  1. #1
    Forum Contributor
    Join Date
    06-24-2013
    Location
    New Zealand
    MS-Off Ver
    Excel 2016
    Posts
    124

    Code works, but takes far too long

    Hi all

    This might be a long shot, but I am stuck for a quicker solution.....

    Can someone help me with my code please? it currently takes two hours to run, or it crashes excel

    Here are the summary points of what it does:
    - Adds and re-names a new sheet for each row in the range
    - Filters and copies results of each row (being employee number) to the newly created sheet
    - Finds the most recent row for each employee position title by deleting the others (row by row, using the: 'if x = x.offest = x'
    - Apply formulas to cells

    I REALLY HOPE SOMEONE CAN GIVE ANY BIT OF HELP, EVEN IF IT'S TO CHANGE ONLY ONE PART!

    Thanks in advance!

    Please Login or Register  to view this content.

  2. #2
    Forum Expert
    Join Date
    10-06-2008
    Location
    Canada
    MS-Off Ver
    2007 / 2013
    Posts
    5,525

    Re: Code works, but takes far too long

    You could start by cleaning up your code.
    Get rid of all the selecting.
    This is an example from your code that is not required.
    Please Login or Register  to view this content.
    Structure your code.
    You dimension all through the +/- 200 lines of code instead of at the beginning.
    etc etc
    I doubt anybody will dig through this mess (forgive me for being non political) and clean it up.
    Google is your best friend.
    A few examples for you.
    https://stackoverflow.com/questions/...t-in-excel-vba
    https://www.spreadsheetsmadeeasy.com...akes-to-avoid/
    https://powerspreadsheets.com/excel-...sential-terms/
    https://source.opennews.org/articles...-spreadsheets/
    Most excel gurus have a tutorial on how to structure code also.

  3. #3
    Forum Contributor
    Join Date
    06-24-2013
    Location
    New Zealand
    MS-Off Ver
    Excel 2016
    Posts
    124

    Re: Code works, but takes far too long

    Thanks!, i really appreciate the tips!

  4. #4
    Forum Expert
    Join Date
    10-06-2008
    Location
    Canada
    MS-Off Ver
    2007 / 2013
    Posts
    5,525

    Re: Code works, but takes far too long

    Maybe explain in a "to the point" manner what you want to achieve.
    The best approach is usually to ask for one problem to be solved at the time.
    It can be sewn together later on.
    You will also see how these helpers structure the code.

    Another small example.
    This
    Please Login or Register  to view this content.
    can be changed to
    Please Login or Register  to view this content.
    You don't need the "TintAndShade" because zero (0) means neutral (no change)
    Last edited by jolivanes; 10-09-2019 at 01:58 AM. Reason: example added

+ 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] Help with code efficiency - routine takes WAY too long to run
    By robertsfd2002 in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 06-24-2018, 07:37 PM
  2. [SOLVED] This code takes way to long to run
    By Jym396 in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 10-31-2017, 11:07 AM
  3. [SOLVED] Translate code takes long time
    By YasserKhalil in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 08-28-2016, 12:58 AM
  4. Inefficient code - macro takes too long
    By dantray02 in forum Excel Programming / VBA / Macros
    Replies: 14
    Last Post: 03-07-2014, 09:29 AM
  5. Code works but takes hours to run.
    By mikemarsha in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 09-28-2013, 02:13 PM
  6. Long code takes an age to run
    By E3iron in forum Excel Programming / VBA / Macros
    Replies: 8
    Last Post: 10-05-2009, 07:38 AM
  7. My Code takes too long to execute
    By coreytroy in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 07-30-2008, 12:12 AM

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