Close all ComboBox dropdowns when I click a button.

dagda13

New Member
Joined
May 18, 2019
Messages
22
Hi, I have a sheet that contains several ComboBoxes embedded directly into the sheet. I have them set up so that when I GotFocus the ComboBox dropdown opens (.DropDown method). However, what I would like to do is clear the ComboBoxes and close the ComboBox drop downs when I click on a button. Clearing the ComboBoxes is simple --- they are linked to cells that I clear by Range. However, I have been unable to find a way to close the ComboBox drop downs. I guess I'm looking for something like a "reverse" .DropDown method, but I've been unable to find any equivalent.
 

Yongle

Well-known Member
Joined
Mar 11, 2015
Messages
4,669
Office Version
365
Platform
Windows
Try this

Code:
Sub Button4_Click()
    Dim objX As OLEObject
    For Each objX In ActiveSheet.OLEObjects
        With objX
            If TypeName(.Object) = "ComboBox" Then
                .Visible = False
                .Visible = True
            End If
        End With
    Next
End Sub
 

DanteAmor

Well-known Member
Joined
Dec 3, 2018
Messages
8,828
Office Version
2007
Platform
Windows
If you select a cell, does the dropdown close?
 

Yongle

Well-known Member
Joined
Mar 11, 2015
Messages
4,669
Office Version
365
Platform
Windows
Thanks for the feedback (y)
 

Forum statistics

Threads
1,082,048
Messages
5,362,890
Members
400,696
Latest member
Kclynn

Some videos you may like

This Week's Hot Topics

  • populate from drop list with multiple tables
    Hi All, i have a drop list that displays data, what i want is when i select one of those from the list to populate text from different tables on...
  • Find list of words from sheet2 in sheet1 before a comma and extract text vba
    Hi Friends, Trying to find the solution on my task. But did not find suitable one to the need. Here is my query and sample file with details...
  • Dynamic Formula entry - VBA code sought
    Hello, really hope one of you experts can help with this - i've spent hours on this and getting no-where. .I have a set of data (more rows than...
  • Listbox Header
    Have a named range called "AccidentsHeader" Within my code I have: [CODE]Private Sub CommandButton1_Click() ListBox1.RowSource =...
  • Complex Heat Map using conditional formatting
    Good day excel world. I have a concern. Below link have a list of countries that carries each country unique data. [URL...
  • Conditional formatting
    Hi good morning, hope you can help me please, I have cells P4:P54 and if this cell is equal to 1 then i want row O to say "Fully Utilised" and to...
Top