Solved

Hide / Show shape, if worksheet is Locked / Unlocked

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

Courses: Start Training Online With Pros, Today

Brush up on the basics or master the advanced techniques required to earn essential industry certifications, with Courses. Enroll in a course and start learning today. Training topics range from Android App Dev to the Xen Virtualization Platform.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Access 2016 7 33
Outlook 2012 VBA: Object missing 14 29
Excel Pivot Chart - Need to show sum of totals 3 17
populate Excel dropdown via ADO and VBA 6 15
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.
This article descibes how to create a connection between Excel and SAP and how to move data from Excel to SAP or the other way around.
This Micro Tutorial demonstrates how to create Excel charts: column, area, line, bar, and scatter charts. Formatting tips are provided as well.
This Micro Tutorial demonstrate the bugs in Microsoft Excel for Mac with Pivot Charts.

815 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

8 Experts available now in Live!

Get 1:1 Help Now