Link to home
Start Free TrialLog in
Avatar of nainil
nainilFlag for United States of America

asked on

Excel Hide button based on condition

I added a button on my excel sheet and assigned a macro to it.

Is it possible to hide the button based on value on a particular cell.. like H1? If H1 contains "pass", only then the button should appear.

This is NOT a COMMAND Button. A simple Form button.
Avatar of hitsdoshi1
hitsdoshi1

if H1="Pass" then
ActiveSheet.SHAPES("Button 1").visible=True
else
ActiveSheet.SHAPES("Button 1").visible=False
Endif

ASKER CERTIFIED SOLUTION
Avatar of hitsdoshi1
hitsdoshi1

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of nainil

ASKER

@jppinto:
How is it supposed to work?

I tried adding the worksheet_change sub... saved the sheet, reopened the same.. the button existed whether or not the value exists in H1.

I opened the sheet you provided, and it works. But, not on my side.

@hitsdoshi1:

how / where do I need to add the code?
Avatar of nainil

ASKER

Never mind, I figured it out :)

Thank you.
With all due respect, why did you accepted the solution from hitsdoshi1? If you use that code, you will get an error because it is missing the object sheet reference! The code is not completed and correct so you shouldn't accept that solution.

I would appreciate your comments on this please.

jppinto
I would appreciate, for future reference, that you at least respond to my question!