+ Reply to Thread
Results 1 to 4 of 4

Enable/Disable Form Button with password

  1. #1
    Forum Contributor
    Join Date
    01-25-2021
    Location
    Atlanta, Georgia
    MS-Off Ver
    365
    Posts
    144

    Enable/Disable Form Button with password

    Hello,

    I have 2 buttons on Sheet1 that either protects or unprotects Sheet2 and Sheet3. I would like buttons to be only enabled if correct password ("1234") is entered into B4.

    Additionally I would like the passcode to automatically erase once I either leave the sheet or close workbook.

    This should be an easy fix but I'm a toddler still learning to walk & talk VBA scripting. Please help....thank you!

    Of course if there is a better way to lock objects I would welcome all advice and criticism.
    Attached Files Attached Files

  2. #2
    Forum Expert
    Join Date
    11-24-2013
    Location
    Paris, France
    MS-Off Ver
    Excel 2003 / 2010
    Posts
    9,831

    Cool Hello, try this !


    According to your attachment :

    • Paste these VBA event procedures to the Sheet1 worksheet module :

    PHP Code: 
    Private Sub Worksheet_Change(ByVal Target As Range)
        If 
    Not Intersect([B5], TargetIs Nothing Then Shapes.Range([{1,2}]).Visible = [B5].Text "1234"
    End Sub

    Private Sub Worksheet_Deactivate()
        [
    B5].ClearContents
    End Sub 

    • Paste this event VBA procedure to the ThisWorkbook module :

    PHP Code: 
    Private Sub Workbook_BeforeSave(ByVal SaveAsUI As BooleanCancel As Boolean)
        
    With Sheet1.[B5]
            If 
    Not IsEmpty(.Value2Then .ClearContents
        End With
    End Sub 
    ► Do you like it ? ► So thanks to click on bottom left star icon « Add Reputation » !

  3. #3
    Forum Contributor
    Join Date
    01-25-2021
    Location
    Atlanta, Georgia
    MS-Off Ver
    365
    Posts
    144

    Re: Hello, try this !

    ahh......so hiding button is better option than disabling.....makes sense.

    Worked beautifully Marc L.....thank you!

  4. #4
    Forum Expert
    Join Date
    11-24-2013
    Location
    Paris, France
    MS-Off Ver
    Excel 2003 / 2010
    Posts
    9,831

    Arrow Re: Enable/Disable Form Button with password


    It's not really a question to be better but as Excel does not have any serious security
    if anyone don't see any button he may not imagine there is some secret VBA procedures inside.

    To add half a level of security you can password protect the VBA project
    and amend each VBA procedure allocated to a button as Private Sub
    in order these VBA procedures are not visible via the Alt F8 key combo …

    Thanks for the rep' !

+ 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. Form Control Start time & End time button enable or disable in sequence coding issue
    By sboy72817 in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 07-06-2016, 07:05 AM
  2. enable disable user form option button group
    By bsapaka in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 11-08-2014, 09:17 PM
  3. enable/disable a command button in User Form w/ condition
    By Bidyut Chakraborty in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 04-02-2014, 03:11 AM
  4. How I do disable and enable web browser control in access form on button click
    By krjoshi in forum Access Programming / VBA / Macros
    Replies: 0
    Last Post: 10-10-2013, 02:58 PM
  5. [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
  6. A password protected Macro to enable and disable other macros?
    By jonvanwyk in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 08-16-2011, 03:04 PM
  7. excel disable save but enable with password prompt?
    By techmob in forum Excel General
    Replies: 6
    Last Post: 06-17-2011, 03:11 PM

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