run time error 1004

khatri milan

New Member
Joined
Nov 6, 2019
Messages
17
i have a control button named "button 61" and a macro is assigned to it, within that macro there is a code : Worksheets("4_Lift Plan").OptionButtons("Button 61").Visible = False which esentially tells to make this same button invisible if certain condition is met and when i run it there is error 1004. Is it wrong to make buttn invisible from within its own code.
 

My Aswer Is This

Well-known Member
Joined
Jul 5, 2014
Messages
16,031
Try this:
Code:
Worksheets("4_Lift Plan").OptionButtons("Option Button 61").Visible = False
 

DanteAmor

Well-known Member
Joined
Dec 3, 2018
Messages
7,666
Office Version
2007
Platform
Windows
How about:

Code:
Worksheets("4_Lift Plan").[COLOR=#0000ff]DrawingObjects[/COLOR]("Button 61").Visible = False
 

dmt32

Well-known Member
Joined
Jul 3, 2012
Messages
5,134
i have a control button named "button 61" and a macro is assigned to it, within that macro there is a code : Worksheets("4_Lift Plan").OptionButtons("Button 61").Visible = False which esentially tells to make this same button invisible if certain condition is met and when i run it there is error 1004. Is it wrong to make buttn invisible from within its own code.

In your code your are referring to an Excel Form Control OptionButton when from what you describe, you really mean Buttons which would explain the error.

try this update

Code:
Worksheets("4_Lift Plan").Buttons("Button 61").Visible = False
Dave
 

Fluff

MrExcel MVP, Moderator
Joined
Jun 12, 2014
Messages
30,113
Office Version
365
Platform
Windows
Alternatively
Code:
Worksheets("4_Lift Plan").Shapes("Button 61").Visible = False
 
Last edited:

DanteAmor

Well-known Member
Joined
Dec 3, 2018
Messages
7,666
Office Version
2007
Platform
Windows
Code:
Worksheets("4_Lift Plan").Buttons("Button 61").Visible = False
Dave

Hi Dave, that alternative does not work for me.

If the button is an Active X Control, this would be another alternative:

Code:
Worksheets("4_Lift Plan").OLEObjects("Button 61").Visible = True
 

dmt32

Well-known Member
Joined
Jul 3, 2012
Messages
5,134
Hi Dave, that alternative does not work for me.

If the button is an Active X Control, this would be another alternative:

Code:
Worksheets("4_Lift Plan").OLEObjects("Button 61").Visible = True
Dante

In my post I clearly stated

In your code your are referring to an Excel Form Control
code works fine for me with a Form Control Button - I just amended posted code for the OP to try.

It maybe for you that your system may need to use the Controls msoTriState enumeration. msoFalse

Dave
 
Last edited:

DanteAmor

Well-known Member
Joined
Dec 3, 2018
Messages
7,666
Office Version
2007
Platform
Windows
Dante

In my post I clearly stated
code works fine for me with a Form Control Button - I just amended posted code for the OP to try.
It maybe for you that your system may need to use the Controls msoTriState enumeration. msoFalse
Dave
Sorry, iIt doesn't work for me for a Form Control Button either, I hope, this works for the OP (it's important)
 

Fluff

MrExcel MVP, Moderator
Joined
Jun 12, 2014
Messages
30,113
Office Version
365
Platform
Windows
Not sure why it doesn't work for you, as it works for me, as long as the object is a button, rather than an option button.
 

DanteAmor

Well-known Member
Joined
Dec 3, 2018
Messages
7,666
Office Version
2007
Platform
Windows
:ROFLMAO: I had the idea that it was an optionbutton, because the OP thus put its instruction. Thanks @Fluff for clarifying it

An apology @dmt32 :banghead: it also works for me for a button.
 

Forum statistics

Threads
1,077,638
Messages
5,335,393
Members
399,015
Latest member
emalabel

Some videos you may like

This Week's Hot Topics

Top