DYNAMIC LISTBOX
You don't say where your listbox is ie worksheet or userform?
sample code below assumes listbox is on a worksheet but approach can be
adapted for userform
Sub AddListboxData()
Dim Rng1 As Range
Dim Val1 As Single
Dim Val2 As Single
Set Rng1 = Worksheets("Sheet2").Range("B5:B20")
With Worksheets("Sheet1")
Set Lbox1 = .ListBox1
Val1 = .Range("A1")
Val2 = .Range("A2")
.ListBox1.Clear
For Each Item In Rng1
Select Case Item
Case Is = Val1, Val2
.ListBox1.AddItem Item
End Select
Next Item
End With
End Sub
--
jb
"daphoenix" wrote:
I would like to know if there is a way to have a listbox return only values
that meet two critera.
Like if Cell A1 = 5 and Cell A2 = 20, i would like only to return the values
located in a diffrent sheet(column B) between rows 5 and 20. Then those
values would be put in the ListBox.
Thanks
|