Solved

Hide / Show shape, if worksheet is Locked / Unlocked

Posted on 2015-01-31
4
99 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 27

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 27

Expert Comment

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

Featured Post

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Since upgrading to Office 2013 or higher installing the Smart Indenter addin will fail. This article will explain how to install it so it will work regardless of the Office version installed.
When you see single cell contains number and text, and you have to get any date out of it seems like cracking our heads.
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.
Finds all prime numbers in a range requested and places them in a public primes() array. I've demostrated a template size of 30 (2 * 3 * 5) but larger templates can be built such 210  (2 * 3 * 5 * 7) or 2310  (2 * 3 * 5 * 7 * 11). The larger templa‚Ķ

839 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