+ Reply to Thread
Results 1 to 2 of 2

Close userform with multiple toolbox inputs with Esc

  1. #1
    Forum Contributor
    Join Date
    08-14-2016
    Location
    Warrington, England
    MS-Off Ver
    MS 365
    Posts
    168

    Close userform with multiple toolbox inputs with Esc

    Hi all,

    I am trying to close a number of userforms where I have stripped them of any headers etc. with buttons to close them down which I have working but from a more accessible user friendly experience I would also like it if the user could just close the userform with the ESC key.

    I have the below code in some of my userforms which works perfectly:

    Please Login or Register  to view this content.
    however this only seems to work on userforms where there are no inputs, so for example a userform where all that is display is labels etc. but where I have dropboxes, comboboxes, textboxes, radio buttons etc. essentially anywhere the focus is taken from the userform and the user can select any of these options, the code doesnt work. I presume because the focus is no longer on the Userform itself but the option within it.

    I worked out that I can essentially copy the above code to keypress events for each individual textbox, radio button, dropbox etc. which does work, but it is a lot of repetition as there are about 30 items on the userform I would need to copy it for. Is there a better way I can do it so that it applies to the userform open, regardless if the user is in the textbox or dropbox etc.

    thanks
    Excel Beginner

  2. #2
    Forum Expert
    Join Date
    08-17-2007
    Location
    Poland
    Posts
    2,224

    Re: Close userform with multiple toolbox inputs with Esc

    Make the [Cancel] button on the user form and name it cmdCancel. You can manually or programmatically assign the Cancel property set to True to this button.
    Below is a schema to do it programmatically.
    Please Login or Register  to view this content.
    Artik

+ 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. [SOLVED] pass multiple inputs from userform back to main routine
    By Coley356 in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 08-19-2022, 07:54 PM
  2. toolbox does not seem to be available while editing userform
    By gwrusr in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 04-06-2022, 01:53 AM
  3. [SOLVED] Control Toolbox does not appear when trying to design a Userform!
    By [email protected] in forum Excel Programming / VBA / Macros
    Replies: 8
    Last Post: 01-31-2019, 11:55 AM
  4. [SOLVED] Userform inputs comparison with sheet cells and if true reset userform fields
    By aidan5800 in forum Excel Programming / VBA / Macros
    Replies: 10
    Last Post: 08-08-2018, 04:51 PM
  5. Calendar Userform without additional Toolbox controls
    By frostii in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 02-20-2015, 04:20 AM
  6. Replies: 3
    Last Post: 06-23-2013, 12:13 AM
  7. [SOLVED] Sticky Toolbox over userform. How can I close it permanently?
    By socratesgb in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 04-12-2013, 10:06 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