+ Reply to Thread
Results 1 to 7 of 7

Change event problem when the user switches worksheet without pressing ENTER

  1. #1
    Registered User
    Join Date
    05-20-2012
    Location
    Mexico
    MS-Off Ver
    Excel 2002
    Posts
    12

    Change event problem when the user switches worksheet without pressing ENTER

    I have a workbook which involves the user switching between two worksheets. On Sheet 2 I am using dynamic data validation lists which the user can add to. The default list includes the option "Add new comment". When this is selected, a change event is triggered, [cell].ClearContents. The user then enters the new comment. Pressing enter will trigger another change event which compares the new comment to the default list and if it is missing, add it to the list. This process works.

    The problem I am having is when the user enters a new comment but then switches worksheet without first pressing enter. The change event still triggers but it is ignoring the new comment, and comparing the cell in its ClearContents state with the default list. With some cells it is giving the ClearContents state a value of '0', but with others a value of 'L' and others a value of '-' !!!! The value of '0' ie, blank cell , I understand but the others?? I've tried a worksheet deactivate event, but it doesn't trigger until the change event has finished. I've also thought of a SendKey return but it returns on the new active window.

    CAUSE IDENTIFIED. IF THE USER CHANGES WORKSHEET BEFORE PRESSING ENTER. THE CHANGE EVENT CODE WILL REFERENCE THE CELLS OF THE ACTIVE IE, NEW WORKSHEET.
    Last edited by franklyn; 09-06-2012 at 11:57 AM.

  2. #2
    Forum Guru TMS's Avatar
    Join Date
    07-15-2010
    Location
    The Great City of Manchester, NW England ;-)
    MS-Off Ver
    MSO 2007,2010,365
    Posts
    48,142

    Re: Change event problem when the user switches worksheet without pressing ENTER

    Someone asked me recently if my crystal ball had failed ... seems it's out of service indefinitely.

    You're listing no code and haven't uploaded a sample workbook.

    I'm not sure what advice or testing you think we can do without any evidence.

    Nice idea by the way.

    Regards, TMS
    Trevor Shuttleworth - Retired Excel/VBA Consultant

    I dream of a better world where chickens can cross the road without having their motives questioned

    'Being unapologetic means never having to say you're sorry' John Cooper Clarke


  3. #3
    Registered User
    Join Date
    05-20-2012
    Location
    Mexico
    MS-Off Ver
    Excel 2002
    Posts
    12

    Re: Change event problem when the user switches worksheet without pressing ENTER

    TMS, humour much appreciated I've added what I believe to be the appropriate code to my original post. Apologies for its naivety.

  4. #4
    Forum Guru TMS's Avatar
    Join Date
    07-15-2010
    Location
    The Great City of Manchester, NW England ;-)
    MS-Off Ver
    MSO 2007,2010,365
    Posts
    48,142

    Re: Change event problem when the user switches worksheet without pressing ENTER

    Sorry, but it would be easier to test in the context of a sample workbook. Only need the salient parts if it's sensitive.

    Regards, TMS

  5. #5
    Registered User
    Join Date
    05-20-2012
    Location
    Mexico
    MS-Off Ver
    Excel 2002
    Posts
    12

    Re: Change event problem when the user switches worksheet without pressing ENTER

    Happy to send you the workbook via email if OK with you. I guess I can do that via your forum membership details page.

  6. #6
    Forum Guru TMS's Avatar
    Join Date
    07-15-2010
    Location
    The Great City of Manchester, NW England ;-)
    MS-Off Ver
    MSO 2007,2010,365
    Posts
    48,142

    Re: Change event problem when the user switches worksheet without pressing ENTER

    It would be simpler to just upload it in the forum. Is there any reason why you can't upload a simplistic example of the workbook? No details are required, just the structure, the list and the cell with the Data Validation being monitored in the WS Change Event.

    If you must, it's a hotmail dot com account ... although this is the NOT preferred option.

    Regards, TMS

  7. #7
    Registered User
    Join Date
    05-20-2012
    Location
    Mexico
    MS-Off Ver
    Excel 2002
    Posts
    12

    Re: Change event problem when the user switches worksheet without pressing ENTER

    OK, I'll prep a simplified version for upload. Best regards.

+ 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