+ Reply to Thread
Results 1 to 6 of 6

Trouble with sub that runs on pressing enter after modifying cell's content

  1. #1
    Valued Forum Contributor luv2glyd's Avatar
    Join Date
    07-13-2008
    Location
    Seattle, WA, US
    MS-Off Ver
    Excel 2010
    Posts
    679

    Smile Trouble with sub that runs on pressing enter after modifying cell's content

    I have the following sub which is designed to run another sub, "mySub", once I change the value of cell H10:

    Please Login or Register  to view this content.
    mySub basically goes to another workbook, modifies some values in it and comes back to the workbook where mySub resides. If I run mySub by itself, it runs fine, but if I attempt to activate it with the code above, it seems to run on a loop, going back and fourth between the two workbook endlessly. Any clues as to why? I used this code before and it worked well.

    Thanks.
    Last edited by luv2glyd; 02-09-2014 at 04:18 PM.
    You either quit or become really good at it. There are no other choices.

  2. #2
    Forum Expert
    Join Date
    01-23-2013
    Location
    USA
    MS-Off Ver
    Microsoft 365 aka Office 365
    Posts
    3,863

    Re: Trouble with sub that runs on pressing enter after modifying cell's content

    Hi,

    You might be modifying "H10" causing WorksheetChange() to fire again.

    If this is the case, you have to tell us what you want to happen when this occurs, in order for us to provide the proper fix for your problem.

    Lewis

  3. #3
    Valued Forum Contributor luv2glyd's Avatar
    Join Date
    07-13-2008
    Location
    Seattle, WA, US
    MS-Off Ver
    Excel 2010
    Posts
    679

    Re: Trouble with sub that runs on pressing enter after modifying cell's content

    Ahhhaa! That could be it. As soon as I modify cell "H10" on my own, mySub goes to the secondary worksheet to do a few things, then comes back and enters another value into "H10" on its own. I did not think Excel would perceive this as me doing it. Anyway, what I'd like to have happen as soon as it comes back to the original worksheet and enters this other value on its own is to simply stop not do anything.

  4. #4
    Forum Expert shg's Avatar
    Join Date
    06-20-2007
    Location
    The Great State of Texas
    MS-Off Ver
    2010, 2019
    Posts
    40,689

    Re: Trouble with sub that runs on pressing enter after modifying cell's content

    Maybe ...

    Please Login or Register  to view this content.
    Entia non sunt multiplicanda sine necessitate

  5. #5
    Valued Forum Contributor luv2glyd's Avatar
    Join Date
    07-13-2008
    Location
    Seattle, WA, US
    MS-Off Ver
    Excel 2010
    Posts
    679

    Re: Trouble with sub that runs on pressing enter after modifying cell's content

    That works! Thank you.

  6. #6
    Forum Expert
    Join Date
    01-23-2013
    Location
    USA
    MS-Off Ver
    Microsoft 365 aka Office 365
    Posts
    3,863

    Re: Trouble with sub that runs on pressing enter after modifying cell's content

    Great answer as usual shg. Thanks for the rep points luv2glyd.

    Sometimes you don't want to disable system events. In that case you can use a global variable of your own to inhibit something. This is a techinque used quite often in UserForms.

    Lewis


    Please Login or Register  to view this content.

+ 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. Reselect cell after pressing enter
    By randell.graybill in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 05-19-2010, 10:38 PM
  2. Alt + Enter when pressing enter in cell?
    By Stiff in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 08-20-2009, 05:31 AM
  3. Auto Jumping to next cell without pressing enter
    By Steve Brown in forum Excel General
    Replies: 1
    Last Post: 01-21-2008, 02:47 PM
  4. Active Cell after pressing the Enter Key
    By RealNewbie in forum Excel General
    Replies: 2
    Last Post: 10-17-2007, 09:56 PM
  5. [SOLVED] HOW DO I GET THE ANSWER TO A FORMULA BY PRESSING ENTER IN CELL?
    By E-QUIP in forum Excel General
    Replies: 1
    Last Post: 05-31-2006, 12:10 PM

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