+ Reply to Thread
Results 1 to 6 of 6

Can someone help me to condense this VBA code - it takes a long time to compute

  1. #1
    Registered User
    Join Date
    02-04-2013
    Location
    London
    MS-Off Ver
    Excel 2010
    Posts
    23

    Can someone help me to condense this VBA code - it takes a long time to compute

    I am trying to carry out a sensitivity analysis, result are presented in a table like format below:

    SAtable.png


    Thank you for your help.

    Please Login or Register  to view this content.

    the code for CopyUntilZero is below:
    Please Login or Register  to view this content.
    Last edited by shayej; 05-11-2023 at 08:38 AM.

  2. #2
    Forum Expert
    Join Date
    05-05-2015
    Location
    UK
    MS-Off Ver
    Microsoft Excel for Microsoft 365 MSO (Version 2402 Build 16.0.17328.20068) 64-bit
    Posts
    28,209

    Re: Can someone help me to condense this VBA code - it takes a long time to compute

    Please see yellow banner on how to attach a sample workbook together with an explanation of what you are doing rather than us having to decipher the code.
    If that takes care of your original question, please select Thread Tools from the menu link above and mark this thread as SOLVED.

  3. #3
    Registered User
    Join Date
    02-04-2013
    Location
    London
    MS-Off Ver
    Excel 2010
    Posts
    23

    Re: Can someone help me to condense this VBA code - it takes a long time to compute

    Sample worksheet ED.xlsm

    Hi I have now attached a simple file.

    basically I begin with inserting a value in F3 and E26 in Rev + Cost worksheet.


    cashflow sheet calculates cashflow over time.

    and when I go to Sensitivity analysis sheet and insert a step size, it changes F3 and E26 values and calculates RV value when cashflow reaches 0 using CopyUntilZero.

    i hope this explains the steps properly.

  4. #4
    Forum Expert
    Join Date
    08-17-2007
    Location
    Poland
    Posts
    2,224

    Re: Can someone help me to condense this VBA code - it takes a long time to compute

    The first thing I see that slows down the execution of the code is using the clipboard to copy data, for example, instead of
    Please Login or Register  to view this content.
    you can write
    Please Login or Register  to view this content.
    and instead of
    Please Login or Register  to view this content.
    use
    Please Login or Register  to view this content.
    You can also abandon Select, which also significantly slows down the operation.
    Below is the code after improvement. I do not exclude that it can be further optimized, but this is a job not for me.
    Please Login or Register  to view this content.
    Artik

  5. #5
    Registered User
    Join Date
    02-04-2013
    Location
    London
    MS-Off Ver
    Excel 2010
    Posts
    23

    Re: Can someone help me to condense this VBA code - it takes a long time to compute

    Thank you so much, it did make the whole process much faster.

  6. #6
    Registered User
    Join Date
    02-04-2013
    Location
    London
    MS-Off Ver
    Excel 2010
    Posts
    23

    Re: Can someone help me to condense this VBA code - it takes a long time to compute

    it used to take 1 min to finish the analysis now it takes just under 8 seconds

+ 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] VBA Code Takes too long to Run
    By rain4uu in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 06-07-2020, 11:02 AM
  2. [SOLVED] how to set up progress display for code that takes a long time
    By kevinu in forum Excel Programming / VBA / Macros
    Replies: 9
    Last Post: 05-24-2018, 05:14 PM
  3. [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
  4. [SOLVED] code ignore different spelling and takes a long time
    By torti111 in forum Excel Programming / VBA / Macros
    Replies: 10
    Last Post: 08-04-2017, 05:14 AM
  5. [SOLVED] Translate code takes long time
    By YasserKhalil in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 08-28-2016, 12:58 AM
  6. The runtime for my code I wrote takes too long, is there a way tocan you condense?
    By dnice0123 in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 03-18-2014, 03:33 AM
  7. 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

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