+ Reply to Thread
Results 1 to 22 of 22

Hide command button if worksheet is protected

Hybrid View

  1. #1
    Forum Guru DonkeyOte's Avatar
    Join Date
    10-22-2008
    Location
    Northumberland, UK
    MS-Off Ver
    O365
    Posts
    21,531

    Re: Hide command button if worksheet is protected

    OK a few points...

    1 - workbook level events (like Workbook_Open) should reside in the Workbook Object which is called ThisWorkbook (ie not in Sheet Object nor standard Module)

    2 - you refer to Sheets("Sheet3") ... the button is seemingly on sheet called "Template" which happens to have Sheet3 codename so to refer to this sheet use either

    a) Sheet3

    or

    b) Sheets("Template")

    3 - the code I gave originally was for an ActiveX Command Button rather than a Forms Command Button... you're using the latter so you will need to revise the code accordingly

    4 - given neither Sheet1 nor Sheet2 (codenames) exist in your sample file you need to remove those lines


    So putting all of the above together the below should be added to ThisWorkbook Object in your sample file

    Private Sub Workbook_Open()
    With Sheet3
        .ScrollArea = "A1:AB23"
        .Shapes("ButtonSave").Visible = UCase(Environ("username")) = "MYUSERNAME"
    End With
    End Sub
    Last edited by DonkeyOte; 10-05-2009 at 05:35 AM. Reason: typos

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

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