+ Reply to Thread
Results 1 to 4 of 4

Worksheet Change Puzzle

  1. #1
    Registered User
    Join Date
    07-05-2007
    Posts
    44

    Worksheet Change Puzzle

    Hi!

    I seem to be in a bit of a logical mess. I have a worksheet set up so that each cell has a data validation list. When someone selects an item from the list, I run Application.Calculate from the Worksheet_Change function because there are other cells that are affected and need to be updated.

    Now, the problem is that I have a few very large macros that change hundreds and hundreds of cells at one time - and when that occurs, you have the Application.Calculate function running hundreds and hundreds of times as well, slowing down the speed considerably.

    I would like to have it both ways if I can - if someone changes one cell, I'd like to run the Application.Calculate, and when a large macro runs, I'd like to put off the Application.Calculate until the very end so it just runs once.

    Any ideas? Thanks!

    Dan

  2. #2
    Forum Contributor
    Join Date
    07-05-2007
    Location
    Lexington, MA
    Posts
    302
    Create a global variable like
    Dim IgnoreCalculate as Boolean
    at the top of a general Module code sheet, outside any subs. It will start out False by default

    Set this while your big subs run, and clear it when finished.

    Check this before executing Application.Calculate in your other sub.

  3. #3
    Valued Forum Contributor mudraker's Avatar
    Join Date
    11-10-2003
    Location
    Melbourne, Australia
    Posts
    3,983
    At the start of the large macro add

    Please Login or Register  to view this content.
    at the end add
    Please Login or Register  to view this content.
    you could also force calculation on just some rows, column, cells by using code like

    Please Login or Register  to view this content.
    the above calculates the formulas in columns A, B, and C in the used range on Sheet1
    Please Read Forum Rules Before Posting
    Wrap VBA code by selecting the code and clicking the # icon or Read This
    How To Cross Post politely

    Top Excel links for beginners to Experts

    If you are pleased with a member's answer then use the Scales icon to rate it
    If my reply has assisted or failed to assist you I welcome your Feedback.

  4. #4
    Registered User
    Join Date
    07-05-2007
    Posts
    44
    Awesome, thanks guys - I went with declaring the public boolean variable. I did this because I have a number of my rows grouped, and if Application.Calculate is ever automatic, it calculates each time I hide or show my rows.

    Thanks again -

    Dan

+ 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