+ Reply to Thread
Results 1 to 5 of 5

VBA disable command button permanently

  1. #1
    Registered User
    Join Date
    03-17-2016
    Location
    Malta
    MS-Off Ver
    2016
    Posts
    2

    VBA disable command button permanently

    Hello everyone,

    I am new to this forum. I have a User Form with several command buttons, and I would like to have a command button disabled permanently after it is clicked.

    The User Form (Welcome_scrn_UserForm) has a button named Start_btn, which calls another Userform named Start_Form, and I would like Start_btn disabled permanently


    This is what I tried and it works, however when I start the Excel again, it is enabled again:

    Welcome_scrn_UserForm.Start_btn.enabled = false


    Is there a way that I do this please? Or do i need to set a command to delete the command button?

    Many thanks in advance!

    Paul

  2. #2
    Forum Contributor kalbasiatka's Avatar
    Join Date
    02-27-2016
    Location
    Brest, Belarus
    MS-Off Ver
    2021
    Posts
    224

    Re: VBA disable command button permanently

    Hi.
    You invite each to draw shapes and play around with the buttons?
    Show an example in the file.
    To do it for me and help me it is 2 different things!
    Sorry for my english, blame Google translator

  3. #3
    Forum Guru sktneer's Avatar
    Join Date
    04-30-2011
    Location
    Kanpur, India
    MS-Off Ver
    Office 365
    Posts
    9,655

    Re: VBA disable command button permanently

    Hi polazzopardi,
    Welcome to the forum.

    One way is to flag a cell on any sheet and check that cell value during the UserForm Initialize event and if the flag is found set the enable property of the button to false.

    In the below code when the UserForm initializes first time it doesn't find the text "Disable" in the cell AAA1 on Sheet1 and once the Start_btn is clicked the button click event places the text "Disable" in the cell AAA1 on Sheet1 and next time when you open the UserForm the Form Initialize event find the text "Disable" in cell AAA1 on Sheet1 and it sets the Enable property of the Start_btn to False and hence the Start-btn is permanently disabled.

    Please Login or Register  to view this content.
    See if this helps.
    Regards
    sktneer


    Treat people the way you want to be treated. Talk to people the way you want to be talked to.
    Respect is earned NOT given.

  4. #4
    Registered User
    Join Date
    03-17-2016
    Location
    Malta
    MS-Off Ver
    2016
    Posts
    2

    Re: VBA disable command button permanently

    Wow, that made the trick. Thank you very much for that.

    Nice weekend!

  5. #5
    Forum Guru sktneer's Avatar
    Join Date
    04-30-2011
    Location
    Kanpur, India
    MS-Off Ver
    Office 365
    Posts
    9,655

    Re: VBA disable command button permanently

    You're welcome Paul! Glad your issue is resolved.

    If that takes care of your original question, please mark your thread as Solved by selecting Thread Tools (just above your first post) --> Mark thread as solved.

    You may also say thanks to those who have put their time and efforts to help you in this forum by clicking the Add Reputation link under their posts, another way to say thanks.

+ 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] Excel VBA - Disable Command button in sub?
    By kickme93 in forum Excel Programming / VBA / Macros
    Replies: 27
    Last Post: 12-10-2013, 08:27 AM
  2. Command Button to disable VBA code?
    By smohs14 in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 09-21-2012, 05:25 PM
  3. [SOLVED] Disable command Button
    By Rick_Stanich in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 05-07-2012, 03:13 PM
  4. [SOLVED] Enable/Disable Command Button
    By rain4uu in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 05-06-2012, 03:27 AM
  5. Disable command button
    By kuraitori in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 07-01-2009, 03:38 AM
  6. Disable Command Button
    By Hasnain in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 03-07-2008, 01:32 PM
  7. Disable Command Button
    By Raj in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 03-10-2006, 01:01 AM
  8. Disable command button
    By Mikeice in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 06-17-2005, 06:05 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