+ Reply to Thread
Results 1 to 15 of 15

Improve code efficiency

  1. #1
    Registered User
    Join Date
    08-06-2009
    Location
    Iceland
    MS-Off Ver
    2016
    Posts
    16

    Improve code efficiency

    Good day mates,


    I'm working on this spreadsheet that is supposed to give a potential customer (owners of ship fleets) an overview of investing in a system that reduces fuel consumption. When I've set up the details for each ship (Implementation Plan), currency, interest rate(DashBoard), etc... and press "Update" (which runs my macros), it can take up to 2 minutes for the sheet until the final calculations are finished.

    I'm not a skilled VBA coder, so the code in the macros is not all by me. Hence my question; is there any way to shorten the calculation cycle? Somehow I would have thought Excel 2007 would do this quite quickly on a decent computer. I would copy the code into here but the whole thing is in 3 or 4 different macros.


    Also, a bit unrelated but still: If any of you are businessmen with education or experience, I would appreciate if you could take a look at the sheet and see if there's anything you can suggest for improvement. My aim with this sheet is to be as clear as possible and make the whole thing easy to understand. But I also may be missing some important aspects of what the investor wants to know? I'm definitely interested in any criticism you can give.


    And finally, if anyone is up for a challenge, I know that for some reason if I change the currency type, (with everything else unchanged) I dont get the same ROI and IRR percentages. They should of course be exactly the same no matter if the figures are displayed in EUR or USD(note that one needs to "Update" in order to recalculate with a new currency). I just can't seem to figure out where I'm doing the mistake. Maybe I've spent too much time on this already, hehe.


    Any assistance greatly appreciated!
    /Eggert
    Attached Files Attached Files
    Last edited by Eggert; 10-14-2009 at 09:22 AM.

  2. #2
    Forum Expert pike's Avatar
    Join Date
    12-11-2005
    Location
    Alstonville, Australia
    MS-Off Ver
    2016
    Posts
    5,330

    Re: Macro takes 2 minutes to calculate - possible to shorten? Business investment cas

    The pro's use excel functions and only use VBA when you can find a excel solution
    There are many loops and that always slows every things down. I seen workbooks larger than yours convert to excel functions with no code that do increaibly calculations in seconds.

    functions are the way to go to save minutes
    If the solution helped please donate to RSPCA

    Site worth visiting: Rabbitohs

  3. #3
    Registered User
    Join Date
    08-06-2009
    Location
    Iceland
    MS-Off Ver
    2016
    Posts
    16

    Re: Macro takes 2 minutes to calculate - possible to shorten? Business investment cas

    Thanks for the input. I will now carefully look at this sheet for possibilities to eliminate code for formulas.

    I would be very interested in seeing one of those large workbooks you mentioned to seek layout ideas and inspiration.

  4. #4
    Forum Expert pike's Avatar
    Join Date
    12-11-2005
    Location
    Alstonville, Australia
    MS-Off Ver
    2016
    Posts
    5,330

    Re: Macro takes 2 minutes to calculate - possible to shorten? Business investment cas

    circular references with interations
    Sorry about the news.Only had a quick peruse and it didnt look good but I have a look/critque and see what I can find

  5. #5
    Forum Expert royUK's Avatar
    Join Date
    11-18-2003
    Location
    Derbyshire,UK
    MS-Off Ver
    Xp; 2007; 2010
    Posts
    26,200

    Re: Macro takes 2 minutes to calculate - possible to shorten? Business investment cas

    Your post does not comply with Rule 1 of our Forum RULES. Your post title should accurately and concisely describe your problem, not your anticipated solution. Use terms appropriate to a Google search. Poor thread titles, like Please Help, Urgent, Need Help, Formula Problem, Code Problem, and Need Advice will be addressed according to the OP's experience in the forum: If you have less than 10 posts, expect (and respond to) a request to change your thread title. If you have 10 or more posts, expect your post to be locked, so you can start a new thread with an appropriate title.
    To change a Title on your post, click EDIT then Go Advanced and change your title, if 2 days have passed ask a moderator to do it for you.
    Hope that helps.

    RoyUK
    --------
    For Excel Tips & Solutions, free examples and tutorials why not check out my web site

    Free DataBaseForm example

  6. #6
    Registered User
    Join Date
    08-06-2009
    Location
    Iceland
    MS-Off Ver
    2016
    Posts
    16

    Re: Macro takes 2 minutes to calculate - possible to shorten? Business investment cas

    Quote Originally Posted by royUK View Post
    Your post does not comply with Rule 1 of our Forum RULES. Your post title should accurately and concisely describe your problem, not your anticipated solution. Use terms appropriate to a Google search. Poor thread titles, like Please Help, Urgent, Need Help, Formula Problem, Code Problem, and Need Advice will be addressed according to the OP's experience in the forum: If you have less than 10 posts, expect (and respond to) a request to change your thread title. If you have 10 or more posts, expect your post to be locked, so you can start a new thread with an appropriate title.
    To change a Title on your post, click EDIT then Go Advanced and change your title, if 2 days have passed ask a moderator to do it for you.
    I paid attention to the rules prior to posting this thread. However, I can't think of another way to rephrase it. Any suggestion?

  7. #7
    Forum Expert royUK's Avatar
    Join Date
    11-18-2003
    Location
    Derbyshire,UK
    MS-Off Ver
    Xp; 2007; 2010
    Posts
    26,200

    Re: Macro takes 2 minutes to calculate - possible to shorten? Business investment cas

    You don't need all those words such as long macro, something like" improve ode efficiency"

  8. #8
    Registered User
    Join Date
    08-06-2009
    Location
    Iceland
    MS-Off Ver
    2016
    Posts
    16

    Re: Macro takes 2 minutes to calculate - possible to shorten? Business investment cas

    Quote Originally Posted by pike View Post
    circular references with interations
    Sorry about the news.Only had a quick peruse and it didnt look good but I have a look/critque and see what I can find
    I don't quite get this post. Could you elaborate?

  9. #9
    Forum Expert pike's Avatar
    Join Date
    12-11-2005
    Location
    Alstonville, Australia
    MS-Off Ver
    2016
    Posts
    5,330

    Re: Improve code efficiency

    Hi Eggert
    Ive attached an example from the master John Walkenback to show how it works and eleminate the need for a looping vba code.
    Attached Files Attached Files

  10. #10
    Registered User
    Join Date
    08-06-2009
    Location
    Iceland
    MS-Off Ver
    2016
    Posts
    16

    Re: Improve code efficiency

    Thanks for that pike. I will have a look and see if I can use it to improve my own document.

  11. #11
    Forum Expert pike's Avatar
    Join Date
    12-11-2005
    Location
    Alstonville, Australia
    MS-Off Ver
    2016
    Posts
    5,330

    Re: Improve code efficiency

    Eggert
    Now that you have had a look at the circular references
    look at this attacment
    It what you will need to do
    To help I'll need all your calx's
    Attached Files Attached Files

  12. #12
    Registered User
    Join Date
    08-06-2009
    Location
    Iceland
    MS-Off Ver
    2016
    Posts
    16

    Re: Improve code efficiency

    I'm not sure that what you explain here, pike, is a solution to my problem. Because the sheet offers the user to enter as many ships as he wants, I cannot replace the code with formulas, at least I don't see a way to.

    So for the time being, the problems are not solved.

  13. #13
    Forum Expert pike's Avatar
    Join Date
    12-11-2005
    Location
    Alstonville, Australia
    MS-Off Ver
    2016
    Posts
    5,330

    Re: Improve code efficiency

    No it was just an example to show how complex caterinary calx can be solved by using named ranges interations and circular references and then graph the results.
    What are your formulae ?

  14. #14
    Registered User
    Join Date
    08-06-2009
    Location
    Iceland
    MS-Off Ver
    2016
    Posts
    16

    Re: Improve code efficiency

    Hi again and thanks for replying.

    But what do you mean "what are your formulas" ? I've got a ton of them, using named ranges etc. Did you check my document?

  15. #15
    Forum Expert pike's Avatar
    Join Date
    12-11-2005
    Location
    Alstonville, Australia
    MS-Off Ver
    2016
    Posts
    5,330

    Re: Improve code efficiency

    Its very hard to follow the functions/code even with tracing so if you have the forumlas it will make it easier

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

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