Two Macros in one worksheet, Macro1 to hide Macro2 button

Amanda H

New Member
Joined
Oct 20, 2022
Messages
8
Office Version
  1. 365
Platform
  1. Windows
The worksheet has two macros.

- macro1 clears all fields and hides rows and columns in worksheet
- macro2 opens a new worksheet

The worksheet asks a series of questions and depending on your response macro2 is applicable.

However, I want macro1 to hide macro2 button from view until the response is applicable.

I have tried to hide the row and column in macro1 but macro2 button is still visible.

Any ideas? thanks.
 

Excel Facts

Copy a format multiple times
Select a formatted range. Double-click the Format Painter (left side of Home tab). You can paste formatting multiple times. Esc to stop
You can use button's Vİsible property
VBA Code:
Sheets("Sheet1").CommandButton1.Visible = False
If somecheck Then
  Sheets("Sheet1").CommandButton1.Visible = True
End If
 
Upvote 0
Or potentially:

VBA Code:
Sheets("Sheet1").Buttons("Button 1").Visible = False
 
Upvote 0
Thank you for your responses.

I had tried that option, but it is only working for the true and not false.

NB: I named the macro button 'shapes' when naming the command button.

See below formula, any help identifying my issue would be greatly appreciated.

1666314458455.png
 
Upvote 0
Thank you for your responses.

I had tried that option, but it is only working for the true and not false.

NB: I named the macro button 'shapes' when naming the command button.

See below formula, any help identifying my issue would be greatly appreciated.


1666314458455.png

Or potentially:

VBA Code:
Sheets("Sheet1").Buttons("Button 1").Visible = False
 
Upvote 0

Forum statistics

Threads
1,215,043
Messages
6,122,825
Members
449,096
Latest member
Erald

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