[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More
Experts Exchange Solution brought to you by
"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.
Do you wonder if your IT business is truly profitable or if you should raise your prices? Learn how to calculate your overhead burden with our free interactive tool and use it to determine the right price for your IT services. Download your free eBook now!
Public Function fnMultiList(lst As ListBox, Optional SelectAll As Boolean = False, _
Optional UseColumn As Integer = -1, _
Optional Delimiter As Variant = Null) As Variant
Dim varItem As Variant
Dim lngItem As Long
Dim strDelimiter As String
fnMultiList = Null
'Determine how to delimit the list items
If UseColumn = -1 Then UseColumn = lst.BoundColumn - 1
If IsNull(Delimiter) = False Then
strDelimiter = Delimiter
ElseIf IsNumeric(lst.Column(UseColumn, Abs(lst.ColumnHeads))) Then
strDelimiter = ""
strDelimiter = Chr$(34)
'loop through the selected items in the list
If lst.MultiSelect = 0 And SelectAll = False Then
fnMultiList = lst.Value
For lngItem = 0 To lst.ListCount
If lst.Selected(lngItem) = True Or SelectAll Then
fnMultiList = (fnMultiList + ",") _
& strDelimiter & lst.Column(UseColumn, lngItem) _
'Strip trailing "," if there is one
If Right(fnMultiList, 1) = "," Then fnMultiList = Left(fnMultiList, Len(fnMultiList) - 1)
'Depending on the number of items selected, determine how the "list values" are returned
If Len(fnMultiList & "") = 0 Then
fnMultiList = " IS NOT NULL"
Select Case Len(fnMultiList) - Len(Replace(fnMultiList, ",", ""))
fnMultiList = " = " & fnMultiList
fnMultiList = " IN (" & fnMultiList & ")"
Open in new window
Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.
From novice to tech pro — start learning today.
Premium members can enroll in this course at no extra cost.