PDA

View Full Version : How to hide VBA combobox on Excel Sheet when it?s drop down?



jiura
10-26-2007, 08:31 AM
Hello to all! I have a VBA combobox on one Excel Sheet and it? is displays when user click on Column B. I use such code:

Private Sub Worksheet_SelectionChange(ByVal Target As Range)

If (Target.Column= Range("B1").Column) Then
Sheets("02").cmb1.Left = Target.Left
Sheets("02"). cmb1.Top = Target.Top
Sheets("02"). cmb1.Width = Target.Width
Sheets("02"). cmb1.Height = Target.Height
cmb1.DropDown
Sheets("02 ").cmb1.Visible = True
End If
'
End Sub

As you see ComboBox drops down. But then If user clicks on other cell not in column B, this combobox must hide, but it doesn?t. I use such code:


Private Sub cmb1_LostFocus()
Cmb1.Visible = False
End Sub

Bob Phillips
10-26-2007, 09:12 AM
Me.oleobjects("cmb1").visible=false