We help IT Professionals succeed at work.

Check out our new AWS podcast with Certified Expert, Phil Phillips! Listen to "How to Execute a Seamless AWS Migration" on EE or on your favorite podcast platform. Listen Now

x

Excel Hide button based on condition

Medium Priority
442 Views
Last Modified: 2012-06-21
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.
Comment
Watch Question

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

Unlock this solution with a free trial preview.
(No credit card required)
Get Preview
Commented:
Unlock this solution with a free trial preview.
(No credit card required)
Get Preview

Author

Commented:
@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?

Author

Commented:
Never mind, I figured it out :)

Thank you.

Commented:
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

Commented:
I would appreciate, for future reference, that you at least respond to my question!
Unlock the solution to this question.
Thanks for using Experts Exchange.

Please provide your email to receive a free trial preview!

*This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

OR

Please enter a first name

Please enter a last name

8+ characters (letters, numbers, and a symbol)

By clicking, you agree to the Terms of Use and Privacy Policy.