Article ID: 126794
Article Last Modified on 10/11/2006
Sub Example1()
DialogSheets(1).ListBoxes(1).ListFillRange = "MyWorksheet!A2:A15"
End Sub
NOTE: "MyWorksheet" is the name of the worksheet that contains the data you
would like placed in the list box.
Sub Example2()
DialogSheets(1).ListBoxes(1).List = _
Array("Mon", "Tue", "Wed", "Thu", "Fri")
End Sub
Sub Example3()
DialogSheets(1).ListBoxes(1).List = _
Worksheets("Sheet1").Range("A1:F1")
End Sub
NOTE: "Sheet1" is the worksheet that contains your data.
Sub Example4()
DialogSheets(1).ListBoxes(1).RemoveAllItems
End Sub
For additional information, please see the following article in the
Microsoft Knowledge Base:
105877 XL: RemoveItem and RemoveAllItems Methods May Not Work
Sub Example6()
Dim LTemp As Variant
Dim LItem As Variant
Dim Counter As Integer
Dim CurList as ListBox
' Set an object name for easy referencing of the list box.
Set CurList = DialogSheets(1).ListBoxes(1)
' Put the Selected array into the variable LTemp.
LTemp = CurList.Selected
' Initialize a Counter variable.
Counter = 1
' Iterate through the loop once for each item in the array.
For Each LItem In LTemp
' If the value of the current item is True...
If LItem = True Then
' Show a message box indicating the item is selected.
MsgBox CurList.List(Counter) & " is selected."
End If
' Increment the Counter to get next selected item.
Counter = Counter + 1
Next
End Sub
For additional information, please see the following article in the
Microsoft Knowledge Base:
124214 XL: Returning a Value from a List Box in Visual Basic
Sub Example6()
Dim LTemp As Variant
Dim LItem As Variant
Dim Counter As Integer
Dim CurList as ListBox
' Set an object name for easy referencing of the list box.
Set CurList = DialogSheets(1).ListBoxes(1)
' Put the Selected array into the variable LTemp.
LTemp = CurList.Selected
' Initialize a Counter variable.
Counter = 1
' Iterate through the loop once for each item in the array.
For Each LItem In LTemp
' If the value of the current item is True...
If LItem = True Then
' Show a message box indicating the item is selected.
MsgBox CurList.List(Counter) & " is selected."
End If
' Increment the Counter to get next selected item.
Counter = Counter + 1
Next
End Sub
For additional information, please see the following article in the
Microsoft Knowledge Base:
111564 XL: Determining Which Items Are Selected in a List Box
Sub Example7()
Dim mtemp As Object
Dim myList
Dim LItem As Variant
' Set mtemp as a ListBox object.
Set mtemp = DialogSheets(1).ListBoxes(1)
' Set mtemp = myList.
myList = mtemp.List
' Create a For-Each Loop.
For Each LItem In myList
' Display the selected item.
MsgBox Litem
Next
End Sub
Additional query words: 5.00a 5.00c Dialogs ListBox XL98 XL97 XL7 XL5 XL
Keywords: kbcode kbhowto kbprogramming KB126794