+ Reply to Thread
Results 1 to 15 of 15

Disable Button Based on Cell Address

  1. #1
    Registered User
    Join Date
    04-06-2021
    Location
    arkansas
    MS-Off Ver
    2016
    Posts
    73

    Disable Button Based on Cell Address

    If the active cell is a2 and i dont want my "Previous" Button to be enabled because the previous cell is the column header (a1).. how do i code the prevbutton.enabled=false

  2. #2
    Registered User
    Join Date
    05-28-2019
    Location
    Newport
    MS-Off Ver
    365
    Posts
    30

    Re: Disable Button Based on Cell Address

    add
    Please Login or Register  to view this content.

    if cell value meets your criteria the button will work, otherwise nothing will happen

    i like this one tbh

    Please Login or Register  to view this content.
    that way a message box comes up if the button is pressed when you don't want it to be.

  3. #3
    Forum Guru Andy Pope's Avatar
    Join Date
    05-10-2004
    Location
    Essex, UK
    MS-Off Ver
    O365
    Posts
    20,428

    Re: Disable Button Based on Cell Address

    You did not provide any information on the type of button so I have assumed ActiveX

    Use the Sheets selection_Change event

    Please Login or Register  to view this content.
    You will probably need to expand on this in your actual file, as it works only when A2 is entered.
    Cheers
    Andy
    www.andypope.info

  4. #4
    Registered User
    Join Date
    04-06-2021
    Location
    arkansas
    MS-Off Ver
    2016
    Posts
    73

    Re: Disable Button Based on Cell Address

    Doesn't seem to work.. and it is a button that comes default from the toolbox.

  5. #5
    Forum Guru Andy Pope's Avatar
    Join Date
    05-10-2004
    Location
    Essex, UK
    MS-Off Ver
    O365
    Posts
    20,428

    Re: Disable Button Based on Cell Address

    The toolbox has 2 button types.

    Post example file
    Welcome to the forum

    Please attach a sample workbook (not a picture or pasted copy). Make sure there is just enough data to demonstrate your need. Include a BEFORE sheet and an AFTER sheet in the workbook if needed to show the process you're trying to complete or automate. Make sure your desired results are shown, mock them up manually if necessary.

    Remember to desensitize the data.

    Click on GO ADVANCED and then scroll down to Manage Attachments to open the upload window.

  6. #6
    Registered User
    Join Date
    04-06-2021
    Location
    arkansas
    MS-Off Ver
    2016
    Posts
    73

    Re: Disable Button Based on Cell Address

    On the Routing Chart Sheet there is a button to open the form.

    My goal is when you click the "previous entry" button that it will no longer
    reach cell A1. It will stop at A2.
    Attached Files Attached Files

  7. #7
    Forum Guru Andy Pope's Avatar
    Join Date
    05-10-2004
    Location
    Essex, UK
    MS-Off Ver
    O365
    Posts
    20,428

    Re: Disable Button Based on Cell Address

    You did not mention this was a userform.

    Modify the open form button code to load first record on open
    Please Login or Register  to view this content.
    Add this code to end of the prevbutton_Click event routine.
    Please Login or Register  to view this content.

  8. #8
    Forum Contributor
    Join Date
    12-02-2020
    Location
    Asia
    MS-Off Ver
    2010 & 2016 insider(Windows 10 64-bit)
    Posts
    724

    Re: Disable Button Based on Cell Address

    @Andy Pope , is it possible do that not ActiveX just normal button?
    I try mod the code but it gives error
    HTML Code: 

  9. #9
    Forum Guru Andy Pope's Avatar
    Join Date
    05-10-2004
    Location
    Essex, UK
    MS-Off Ver
    O365
    Posts
    20,428

    Re: Disable Button Based on Cell Address

    You do not need that sheet event code.

    As I said you did not mention at the start that this was a userform. I assumed the Next/Previous buttons where on the worksheet.

    All the navigation buttons are on a userform so you just need the code provided for userform button events.

  10. #10
    Forum Contributor
    Join Date
    12-02-2020
    Location
    Asia
    MS-Off Ver
    2010 & 2016 insider(Windows 10 64-bit)
    Posts
    724

    Re: Disable Button Based on Cell Address

    just curiosity without use userform

  11. #11
    Forum Guru Andy Pope's Avatar
    Join Date
    05-10-2004
    Location
    Essex, UK
    MS-Off Ver
    O365
    Posts
    20,428

    Re: Disable Button Based on Cell Address

    You can not disable a Forms control.
    You would need to check row in the assigned macro and then process the code or exit the sub.

  12. #12
    Forum Contributor
    Join Date
    12-02-2020
    Location
    Asia
    MS-Off Ver
    2010 & 2016 insider(Windows 10 64-bit)
    Posts
    724

    Re: Disable Button Based on Cell Address

    so if I decide writing in specific value in cell B2 like "OK" then should enable the button and run the macro and if the cell B2 is empty should disable the button and doesn't run the macro
    is it possible ?

  13. #13
    Forum Guru Andy Pope's Avatar
    Join Date
    05-10-2004
    Location
    Essex, UK
    MS-Off Ver
    O365
    Posts
    20,428

    Re: Disable Button Based on Cell Address

    You can not disable the button. Your code would be something like this

    Please Login or Register  to view this content.

  14. #14
    Forum Contributor
    Join Date
    12-02-2020
    Location
    Asia
    MS-Off Ver
    2010 & 2016 insider(Windows 10 64-bit)
    Posts
    724

    Re: Disable Button Based on Cell Address

    thanks for your time

  15. #15
    Registered User
    Join Date
    04-06-2021
    Location
    arkansas
    MS-Off Ver
    2016
    Posts
    73

    Re: Disable Button Based on Cell Address

    works great! only problem is now the first input box no longer gets focus upon opening the userform.

    [edit] i was using the .enabled which was not allowing the text box to gain focus. I instead found the .locked and now it is working as intended.. thank you very much for your help. it is very much appreciated.
    Last edited by bashscript; 05-19-2021 at 10:26 AM. Reason: fixed it

+ 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] Disable/Enable Button based on Cell Value
    By mlo_omg in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 05-03-2021, 11:51 AM
  2. Disable submit button based on class availability
    By china99boy in forum Access Tables & Databases
    Replies: 1
    Last Post: 10-02-2019, 11:42 AM
  3. [SOLVED] hide/disable button based on cell value
    By dori2o in forum Excel General
    Replies: 4
    Last Post: 11-09-2017, 06:53 PM
  4. 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
  5. [SOLVED] Disable a command button yet enable it based on other conditions
    By chin67326 in forum Excel Programming / VBA / Macros
    Replies: 19
    Last Post: 12-23-2015, 08:37 AM
  6. Radio button enable/disable based on data in table
    By oscarmiike in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 10-07-2015, 01:37 AM
  7. [SOLVED] Enable Disable spin button based on a textbox
    By forrestgump1980 in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 03-21-2015, 07:21 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