View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
Leith Ross[_421_] Leith Ross[_421_] is offline
external usenet poster
 
Posts: 1
Default need form pulldown white while box is color


Hello Steve,

If we had access to window handles in VBA this would be easy. This cod
is a work around to your problem. You specify the backcolor of eac
ComboBox (aka Pull Down or Drop Down) in the UserForm's intializ
event. When the user clicks the drop down arrow, the backcolor propert
is set to white. When clicked a second time or when the focus is lost
the backcolor is restored to your original color. All the color value
are RGB values.

You need to add a line of code to each ComboBox's DropDownClick even
to call the backcolor macro. This was easiest code method I coul
devise. The code is in 2 parts: First the UserForm event codes, an
secod the macro module. I use only 2 ComboBoxes in this example, bu
you can you use as many as you need.

USERFORM EVENT COD
_____________________________


Code
-------------------
Private Sub ComboBox1_DropButtonClick()

Call ChangeBackColor(ComboBox1)

End Sub

Private Sub ComboBox2_DropButtonClick()

Call ChangeBackColor(ComboBox2)

End Sub

Private Sub UserForm_Initialize()

On Error Resume Next
With ComboList
.Add vbBlue, ComboBox1.Name
.Add vbYellow, ComboBox2.Name
End With
If Err.Number = 457 Then Err.Clear

End Sub
_____________________________

MACRO MODULE COD
_____________________________

Public ShowList As Boolean
Public ComboList As New Collection

Public Sub ChangeBackColor(ByRef CB As MSForms.ComboBox)

ID = CB.Name

With CB
If Not ShowList Then
.BackColor = vbWhite
Else
.BackColor = Val(ComboList(ID))
End If
End With

ShowList = Not ShowList

End Sub

-------------------

_____________________________

Happy Holidays,
Leith Ros

--
Leith Ros
-----------------------------------------------------------------------
Leith Ross's Profile: http://www.excelforum.com/member.php...fo&userid=1846
View this thread: http://www.excelforum.com/showthread.php?threadid=49593