Solved

Hide / Show shape, if worksheet is Locked / Unlocked

Posted on 2015-01-31
4
91 Views
Last Modified: 2016-02-10
Hello Experts,

Please view attached screenshot.

togglehide.PNG
In the screenshot above, the worksheet is locked.  Is there VBA code (I assume that is the only way to accomplish this) that will look at the "Employees" worksheet, and if the worksheet IS locked, then the "Toggle" button is INVISIBLE.  And when the worksheet is unlocked, then the "Toggle" button is VISIBLE.

Every worksheet has it's own toggle button that I will be applying this to.

I assume you will need to know the name of the "Toggle" button, but I don't know where to find it's name, or even if it does in fact have a unique name.  

Thank you in advance for your help!
0
Comment
Question by:Geekamo
  • 2
4 Comments
 
LVL 29

Expert Comment

by:gowflow
ID: 40581448
Could you just post the workbook ?
Yes we can do this via VBA
gowflow
0
 
LVL 26

Accepted Solution

by:
MacroShadow earned 500 total points
ID: 40581560
This is the syntax you require.
    ' for an ActiveX button
    Me.ButtonName.Visible = ActiveSheet.ProtectContents = True
    ' for a Form button
    ActiveSheet.Shapes("ButtonName").Visible = ActiveSheet.ProtectContents = True

Open in new window

Every control (including buttons have a unique name, to find that name right click on the control (you may have to click on "Design" from the developer tab first), the name will be visible in the "Name" drop-down box on the top right corner of your screen, or type
?Selection.Name

Open in new window

and hit ENTER in the immediate window (Ctrl+G to open it)
0
 
LVL 1

Author Comment

by:Geekamo
ID: 40583109
Thank you MacroShadow! :)
0
 
LVL 26

Expert Comment

by:MacroShadow
ID: 40583292
You're welcome, glad to be of assistance.
0

Featured Post

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

Improved? Move/Copy Add-in Replacement - How to avoid the annoying, “A formula or sheet you want to move or copy contains the name XXX, which already exists on the destination worksheet.” David Miller (dlmille)  It was one of those days… I wa…
Workbook link problems after copying tabs to a new workbook? David Miller (dlmille) Intro Have you either copied sheets to a new workbook, and after having saved and opened that workbook, you find that there are links back to the original sou…
The viewer will learn how to simulate a series of coin tosses with the rand() function and learn how to make these “tosses” depend on a predetermined probability. Flipping Coins in Excel: Enter =RAND() into cell A2: Recalculate the random variable…
This Micro Tutorial demonstrates in Microsoft Excel how to consolidate your marketing data by creating an interactive charts using form controls. This creates cool drop-downs for viewers of your chart to choose from.

743 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now