+ Reply to Thread
Results 1 to 7 of 7

Run Time on Delete

  1. #1
    Forum Contributor
    Join Date
    02-05-2010
    Location
    Exeter, England
    MS-Off Ver
    Excel 2007 & 2010
    Posts
    180

    Run Time on Delete

    Hi,

    The attached WB has 2 unlocked areas (yellow/red), and to unlock a row the user inserts a "#" into column A (yellow)- works fine. The delete button deletes an entire row- works fine, however the problem is that when a user deletes a line directly above the # line the thing hangs for quite some time and I dont know why. Is there some conflict between the two codes?

    Thanks
    Chris
    Attached Files Attached Files
    Last edited by zimbo109; 03-21-2010 at 07:33 AM.

  2. #2
    Forum Expert JBeaucaire's Avatar
    Join Date
    03-21-2004
    Location
    Bakersfield, CA
    MS-Off Ver
    2010, 2016, Office 365
    Posts
    33,492

    Re: Run Time on Delete

    Try this... I moved the protection controls into a worksheet_activate macro which gives all other macros permission to run even though the sheet is protected...that's the UserInterfaceOnly flag.

    Then on the button macro we just turn off other macros while we're deleting so it doesn't trigger the worksheet_change macro that self-runs on the same sheet.
    Attached Files Attached Files
    _________________
    Microsoft MVP 2010 - Excel
    Visit: Jerry Beaucaire's Excel Files & Macros

    If you've been given good help, use the icon below to give reputation feedback, it is appreciated.
    Always put your code between code tags. [CODE] your code here [/CODE]

    ?None of us is as good as all of us? - Ray Kroc
    ?Actually, I *am* a rocket scientist.? - JB (little ones count!)

  3. #3
    Valued Forum Contributor tony h's Avatar
    Join Date
    03-14-2005
    Location
    England: London and Lincolnshire
    Posts
    1,187

    Re: Run Time on Delete

    Hi,
    I put a debug.print line in at the beginning and end of the subroutines to see what was happening

    This was from a delete. The button event runs and causes the change to run.
    on the "change ... end line " the number is the nuber of times the cell.EntireRow.Locked = False line is executed.

    10:39:45 button $A$9
    10:39:47 change $9:$9
    10:39:47 change 0 ... end no changes on a normal delete
    10:39:47 button ... end

    entered #
    10:39:55 change $A$8
    10:39:55 change 1 ... end # entered

    delete on line above #
    10:40:02 button $A$7
    10:40:04 change $7:$7
    10:40:14 change 16384 ... end delete on line above #
    10:40:14 button ... end

    So your problem is clearly shows up here!

    Please Login or Register  to view this content.


    click on the * Add Reputation if this was useful or entertaining.

  4. #4
    Forum Contributor
    Join Date
    02-05-2010
    Location
    Exeter, England
    MS-Off Ver
    Excel 2007 & 2010
    Posts
    180

    Re: Run Time on Delete

    Thanks for your replies, however - Jerry I recieve an error "unable to set the locked property of the range class"
    Tony, still have the same runtime?

    Regards
    Chris

  5. #5
    Forum Contributor
    Join Date
    02-05-2010
    Location
    Exeter, England
    MS-Off Ver
    Excel 2007 & 2010
    Posts
    180

    Re: Run Time on Delete

    Jerry,

    I have got your version working!! not sure what I did - but it works!!

    Thanks Again
    Chris

  6. #6
    Valued Forum Contributor tony h's Avatar
    Join Date
    03-14-2005
    Location
    England: London and Lincolnshire
    Posts
    1,187

    Re: Run Time on Delete

    Quote Originally Posted by zimbo109 View Post
    Tony, still have the same runtime?
    As your original question was "is there some conflict between the code?" I only posted information that would enable you to understand the problem that was occuring and allow you to determine a solution .. for which there are many.


    Why do you think you are getting 16384 loops of the code?


  7. #7
    Forum Contributor
    Join Date
    02-05-2010
    Location
    Exeter, England
    MS-Off Ver
    Excel 2007 & 2010
    Posts
    180

    Re: Run Time on Delete

    Thanks Tony, I understand that now you have highlighted it. I have used Jerrys code to let one macro run whilst the other is not activated.

    Thanks again
    Chris

+ 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