Hide/unhide a button based on selection in a combobox

J

Johanna Gronlund

Hello,

I have a problem that I would appreciate your input on.

The excel file that I am working on has a combobox (Drop Down 573) on sheet
"Results". The cell link is to cell T13 on the same sheet. When T13 = 4, I
would like a button to appear (by this I mean be visible). Does anyone have
any ideas how this might be done?

Thanks,

Johanna
 
D

Dave Peterson

You can use a macro that's assigned to the dropdown.

I added a button from the Forms toolbar (not the control toolbox toolbar). I
named it Button 1. You'll have to modify the code to use the correct name for
your button.

Then I assigned this macro to the dropdown (rightclick on the dropdown and
select "Assign Macro").

Option Explicit
Sub testme()
Dim myDD As DropDown
Dim myButton As Button

With ActiveSheet
Set myButton = .Buttons("Button 1")
Set myDD = .DropDowns(Application.Caller)
If myDD.ListIndex = 4 Then
myButton.Visible = True
Else
myButton.Visible = False
End If
End With

End Sub

If you're new to macros:

Debra Dalgleish has some notes how to implement macros here:
http://www.contextures.com/xlvba01.html

David McRitchie has an intro to macros:
http://www.mvps.org/dmcritchie/excel/getstarted.htm

Ron de Bruin's intro to macros:
http://www.rondebruin.nl/code.htm

(General, Regular and Standard modules all describe the same thing.)
 
J

Johanna Gronlund

Thank you for the detailed instructions. It worked like a dream!

Johanna
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top