yes..
![]()
Sub showCMD() If Sheets(1).Range("A1").value = 1 Then Sheets(1).CommandButton1.Visible = False Else Sheets(1).CommandButton1.Visible = True End If End Sub
yes..
![]()
Sub showCMD() If Sheets(1).Range("A1").value = 1 Then Sheets(1).CommandButton1.Visible = False Else Sheets(1).CommandButton1.Visible = True End If End Sub
Hello Lee & Steve,
Here is way to write the macro so the button name isn't hard code into the macro. This way the macro can be assigned to a Button without knowing its name. This works only with Forms buttons, not Control Toolbox command buttons.
Sincerely,![]()
Sub HideButton() With ActiveSheet.Buttons(Application.Caller) If Range("A1").Value = 1 Then .Visible = False Else .Visble = True End If End With End Sub
Leith Ross
Thank you very much!
One silly questions, if the button was called "Button 42" how is that effected?
I changed "CommandButton1" to "Button42" and "CommandButton42" but it didn't work.. any idea?
Cheers once more,
Lee
have a look at the properties of the bottom and be sure you are referring to by its (name)....Not its caption.
Thanks Leith and Steve
The problem in both scenarios for me is that there are several buttons on the sheet.. The one I need to hide is "Button42".
How is this effected in the vba code?
Thanks again,
Lee
Hello Lee,
Just add the button name into the string variable Button_Name.
Sincerely,![]()
Sub HideButton() Dim Button_Name As String Button_Name = "Button42" With ActiveSheet.Buttons(Button_Name) If Range("A1").Value = 1 Then .Visible = False Else .Visble = True End If End With End Sub
Leith Ross
Thanks again Leith![]()
There are currently 1 users browsing this thread. (0 members and 1 guests)
Bookmarks