Hide or Unhide a "Commandbutton" on a worksheet using VBA code

jmk15315

Board Regular
Joined
Nov 7, 2021
Messages
73
Office Version
  1. 2013
  2. 2010
Platform
  1. Windows
I am using a Userform to drive through a workbook. I am using the same worksheet for "Admin" use as well as "User" functions. Is there a way to hide/unhide commandbuttons on the worksheet so they do not appear when the user unhides the worksheet, but do appear when the sheet is accessed by an Admin?

I know how to make this function work within a Userform, but hoping there is a way to perform this in a worksheet.
 

Excel Facts

Ambidextrous Undo
Undo last command with Ctrl+Z or Alt+Backspace. If you use the Undo icon in the QAT, open the drop-down arrow to undo up to 100 steps.
Is there a way to hide/unhide commandbuttons on the worksheet so they do not appear when the user unhides the worksheet, but do appear when the sheet is accessed by an Admin?
Is it an activex commandbutton?
If you want to refer to the control from a code module, try something like this:
VBA Code:
Sheets("Sheet1").CommandButton1.Visible = False

but do appear when the sheet is accessed by an Admin?
How do you determine if the sheet is accessed by an Admin?
 
Upvote 1
It is not an activex command button. But could be very easily. The sheet is accessed from a userform to make the selection as to which “sheets” to open.
I thought about it being as simple as your suggestion, but I cannot find the identifier for the button name.
 
Upvote 0
No, the buttons are on one sheet, but it was not an ActiveX button, changing the button to ActiveX instead of using a Form Control button fixed my issue.

Thank You!!!
 
Upvote 0
You're welcome, glad to help & thanks for the feedback.:)
 
Upvote 0

Forum statistics

Threads
1,223,893
Messages
6,175,241
Members
452,622
Latest member
Laura_PinksBTHFT

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top