+ Reply to Thread
Results 1 to 5 of 5

Long Calculation Loop Upon Update

  1. #1
    Valued Forum Contributor Miraun's Avatar
    Join Date
    04-03-2009
    Location
    New England
    MS-Off Ver
    2003, 2007, 2010, 2013
    Posts
    554

    Long Calculation Loop Upon Update

    Hi Everyone;

    My current task is to create a spreadsheet that will auto-hide/show rows based upon values in other cells. I am currently about halfway 40% complete with this aspect of the file. I've read over many forums, and the best what that I've seen individuals do it on other sample spreadsheets posted were a =Rand() in a random cell somewhere in the sheet, and a Private Sub worksheet_calculate()

    I'm far from a VBA expert. I'm trying to learn as I go along. Here is my current VBA:

    Please Login or Register  to view this content.
    It was only when I added the
    Please Login or Register  to view this content.
    clause that it began to do a 5 second long update process upon any cell value changing.

    I'm looking for how to set my VBA code to automatically update Hidden and unhidden fields, but without this 3 second updating calculation pause. Any help/advice?
    Last edited by Miraun; 09-02-2009 at 03:12 PM.

  2. #2
    Forum Moderator Leith Ross's Avatar
    Join Date
    01-15-2005
    Location
    San Francisco, Ca
    MS-Off Ver
    2000, 2003, & 2010
    Posts
    23,258

    Re: Long Calculation Loop Upon Update

    Hello Miraun,

    Whenever you right code for a worksheet event like Calculate, Change, or SelectionChange, you should disable the event so it doesn't retrigger when your code modifies the worksheet. Use Application.EnableEvents to turn the events on and off by setting the statement True or False, respectively.
    Please Login or Register  to view this content.
    Sincerely,
    Leith Ross

    Remember To Do the Following....

    1. Use code tags. Place [CODE] before the first line of code and [/CODE] after the last line of code.
    2. Thank those who have helped you by clicking the Star below the post.
    3. Please mark your post [SOLVED] if it has been answered satisfactorily.


    Old Scottish Proverb...
    Luathaid gu deanamh maille! (Rushing causes delays!)

  3. #3
    Forum Guru DonkeyOte's Avatar
    Join Date
    10-22-2008
    Location
    Northumberland, UK
    MS-Off Ver
    O365
    Posts
    21,531

    Re: Long Calculation Loop Upon Update

    And whenever disabling events it's always a good idea to put in place an error handler so as to ensure events are always enabled upon completion regardless of failure/success of the routine as a whole.

  4. #4
    Valued Forum Contributor Miraun's Avatar
    Join Date
    04-03-2009
    Location
    New England
    MS-Off Ver
    2003, 2007, 2010, 2013
    Posts
    554

    Re: Long Calculation Loop Upon Update

    Quote Originally Posted by DonkeyOte View Post
    And whenever disabling events it's always a good idea to put in place an error handler so as to ensure events are always enabled upon completion regardless of failure/success of the routine as a whole.
    By this, do you mean a small, separate sub I can run in case the macro gets interrupted, which would just enable events?

    Or is there a fancier VBA I could throw in there that would automatically do that for me?

  5. #5
    Forum Guru DonkeyOte's Avatar
    Join Date
    10-22-2008
    Location
    Northumberland, UK
    MS-Off Ver
    O365
    Posts
    21,531

    Re: Long Calculation Loop Upon Update

    You do this in the same sub, ie one approach...

    Please Login or Register  to view this content.
    For more info on error handling see: http://www.cpearson.com/excel/ErrorHandling.htm

+ 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