All,
I have a userform with a multiselect listbox used for search and filter options. When the user selects a value in the list box I want it to highlight light green to indicate to the user that a filter is in place. However for a multiselect listbox it will not change the backcolor - at all. Even if I set the backcolor of the listbox in the form design it is changed back to white when the form runs. Does anyone know how to change the backcolor of a multiselect listbox?
-Joshua
If it's not broken, it doesn't have enough parts yet.
I have a userform with a multiselect listbox used for search and filter options. When the user selects a value in the list box I want it to highlight light green to indicate to the user that a filter is in place. However for a multiselect listbox it will not change the backcolor - at all. Even if I set the backcolor of the listbox in the form design it is changed back to white when the form runs. Does anyone know how to change the backcolor of a multiselect listbox?
Code:
Private Sub lstField2_Change()
If Loading = True Then: Exit Sub
If HasItemsSelected(lstField2) = True Then
[highlight]lstField2.BackColor = lngcButtonColorGreen[/highlight]
Else
lstField2.BackColor = lngcFontColorWhite
End If
End Sub
Public Function HasItemsSelected(ListBox As MSForms.Control, Optional ExceptIDs As Variant) As Boolean
Dim F As Long
Dim G As Long
Dim lngIDs() As Long
Dim lngCount As Long
Dim vntCatch As Variant
If TypeOf ListBox Is MSForms.ListBox Or TypeOf ListBox Is MSForms.ComboBox Then
If ListBox.ListCount > 0 Then
lngIDs = ExtractIDs(ExceptIDs, False)
On Error Resume Next
lngCount = UBound(lngIDs)
On Error GoTo 0
For F = 0 To ListBox.ListCount - 1
If ListBox.Selected(F) = True Then
HasItemsSelected = True
'Test exceptions
If lngCount > 0 Then
vntCatch = ListBox.List(F, 0)
If IsNumeric(vntCatch) Then
For G = 1 To lngCount
If vntCatch = lngIDs(G) Then
HasItemsSelected = False
Exit For
End If
Next G
End If
End If
If HasItemsSelected = True Then
Exit For
End If
End If
Next F
End If
End If
End Function
-Joshua
If it's not broken, it doesn't have enough parts yet.