+ Reply to Thread
Results 1 to 6 of 6

Userform command buttons, close on click

  1. #1
    Forum Contributor
    Join Date
    11-10-2009
    Location
    Perth, Australia
    MS-Off Ver
    Excel 2007
    Posts
    549

    Userform command buttons, close on click

    With a userform command button, you can use the code below to close the form.
    But if I have multiple buttons, and if any are clicked, how do I close the form.

    At the same time as closing I want to copy the character in the "Caption" field.



    Please Login or Register  to view this content.
    Untitled2.png
    Attached Images Attached Images

  2. #2
    Forum Guru
    Join Date
    09-10-2017
    Location
    Chippenham, England
    MS-Off Ver
    365
    Posts
    15,079

    Re: Userform command buttons, close on click

    Hi create a new class module, call it CBtns & paste this into it
    Formula: copy to clipboard
    Please Login or Register  to view this content.
    Then in the userform Module
    Please Login or Register  to view this content.
    The line in red must be at the top of the module, before any code.

  3. #3
    Forum Contributor
    Join Date
    11-10-2009
    Location
    Perth, Australia
    MS-Off Ver
    Excel 2007
    Posts
    549

    Re: Userform command buttons, close on click

    Thanks this works, to copy:

    Please Login or Register  to view this content.
    Last edited by Un-Do Re-Do; 07-14-2019 at 07:37 AM.

  4. #4
    Forum Guru
    Join Date
    09-10-2017
    Location
    Chippenham, England
    MS-Off Ver
    365
    Posts
    15,079

    Re: Userform command buttons, close on click

    You cannot copy the caption as such, but you could declare a global variable and use
    Please Login or Register  to view this content.

  5. #5
    Forum Contributor
    Join Date
    11-10-2009
    Location
    Perth, Australia
    MS-Off Ver
    Excel 2007
    Posts
    549

    Re: Userform command buttons, close on click

    Hi thanks, I reposted at #3.

  6. #6
    Forum Guru
    Join Date
    09-10-2017
    Location
    Chippenham, England
    MS-Off Ver
    365
    Posts
    15,079

    Re: Userform command buttons, close on click

    Glad you sorted it & thanks for the feedback

+ 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. Cannot click on command buttons
    By rthell in forum Excel General
    Replies: 2
    Last Post: 12-30-2014, 12:09 PM
  2. Replies: 2
    Last Post: 05-03-2014, 02:19 PM
  3. Stop exit event of textbox firing when click a command button to close a userform
    By chrisjames25 in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 10-18-2013, 09:27 AM
  4. use a command button to click other command buttons
    By fcharl9 in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 09-20-2013, 08:48 PM
  5. Userform: Can you capture the selections from command buttons and call macros on close
    By darrenkaye in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 02-23-2013, 06:34 AM
  6. Code a Command Button on UserForm not to close upon click - Excel VBA
    By eemiller1997 in forum Excel Programming / VBA / Macros
    Replies: 14
    Last Post: 12-14-2012, 02:20 PM
  7. Double click problem with command buttons on userform
    By PaulC in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 10-15-2007, 08:22 AM

Tags for this Thread

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