+ Reply to Thread
Results 1 to 6 of 6

Disable control form textbox button assigned to Macro on excel worksheet

  1. #1
    Forum Contributor
    Join Date
    06-06-2013
    Location
    London
    MS-Off Ver
    Excel 2010
    Posts
    180

    Disable control form textbox button assigned to Macro on excel worksheet

    Hi all, I am trying to disable a control form textbox button called "step1button" I have tried the following but no luck:-

    sheet1.step1button.enabled = False

    but i get a compile error member or method not found

    Any help greatly appreciated as usual.

    Kind regards,

    James Elwell

  2. #2
    Forum Expert Arkadi's Avatar
    Join Date
    02-13-2014
    Location
    Smiths Falls, Ontario, Canada
    MS-Off Ver
    Office 365
    Posts
    5,059

    Re: Disable control form textbox button assigned to Macro on excel worksheet

    Hi James,


    Truth is setting the enabled property to false on a form control type button will not stop it from executing its code... but you are looking for

    Please Login or Register  to view this content.
    This will, as I said, not stop it from executing code, you could however change the macro that runs from the button to include a check and only run the code if the button is enabled:
    Please Login or Register  to view this content.
    Last edited by Arkadi; 02-08-2017 at 12:18 PM.
    Please help by:

    Marking threads as closed once your issue is resolved. How? The Thread Tools at the top
    Any reputation (*) points appreciated. Not just by me, but by all those helping, so if you found someone's input useful, please take a second to click the * at the bottom left to let them know

    There are 10 kinds of people in this world... those who understand binary, and those who don't.

  3. #3
    Registered User
    Join Date
    02-08-2017
    Location
    Scotland
    MS-Off Ver
    Office 365
    Posts
    21

    Re: Disable control form textbox button assigned to Macro on excel worksheet

    alternatively, hide the button.... ".visible = False"

  4. #4
    Forum Expert Arkadi's Avatar
    Join Date
    02-13-2014
    Location
    Smiths Falls, Ontario, Canada
    MS-Off Ver
    Office 365
    Posts
    5,059

    Re: Disable control form textbox button assigned to Macro on excel worksheet

    Good point RdwJ! I assumed the OP did not want it to disappear, but I should have thought to suggest it... nice call.

  5. #5
    Forum Contributor
    Join Date
    06-06-2013
    Location
    London
    MS-Off Ver
    Excel 2010
    Posts
    180

    Re: Disable control form textbox button assigned to Macro on excel worksheet

    Hi there,

    I tried the following:-
    Please Login or Register  to view this content.
    But I got the following message:-

    Run time error 1004
    "Method Buttons of object_worksheet failed"

    Not sure what i am doing incorrect but i'm no expert!

  6. #6
    Forum Expert Arkadi's Avatar
    Join Date
    02-13-2014
    Location
    Smiths Falls, Ontario, Canada
    MS-Off Ver
    Office 365
    Posts
    5,059

    Re: Disable control form textbox button assigned to Macro on excel worksheet

    Can you provide the workbook? Clean out any sensitive data of course, but I can't replicate the problem, if the sheet reference is the issue the error should be different, same with button name. Tried with a protected and hidden sheet, and still couldn't duplicate the problem.

    One thing you could try is changing
    Please Login or Register  to view this content.
    to
    Please Login or Register  to view this content.
    a button should not have a True or False value, rather its Enabled property can be true or false.
    I don't think that's your issue though, because the error should be a different one " Run-time error 438.
    One thing to make sure is that there is a Sheet1. This is not the NAME but the code name (the part not in brackets in the VBA editor). If you want to refer to it by name it is Worksheets("Sheet1").Buttons...

+ 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. VBA to hide or disable a form control button based on cell value
    By npsnps in forum Excel Programming / VBA / Macros
    Replies: 13
    Last Post: 01-11-2017, 06:40 AM
  2. [SOLVED]VBA - Button(Form Control)-Disable/Enable->Alternate Solution
    By mcmunoz in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 09-20-2013, 02:56 AM
  3. [SOLVED] Form control button not retaining assigned macro name
    By sinistr0311 in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 07-17-2013, 02:13 AM
  4. [SOLVED] Macro To Open A Hidden Worksheet When Button (Form Control) Is Clicked
    By obwales in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 10-25-2012, 12:55 AM
  5. Disable Form button in excel worksheet
    By uvaidya in forum Excel General
    Replies: 0
    Last Post: 08-10-2012, 07:16 AM
  6. Assigned Macro to Combo Box(Form Control)
    By pantus in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 11-18-2009, 04:43 PM
  7. macro assigned to a form control button in a protected worksheet
    By lee_har in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 10-09-2009, 02:29 AM

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