DYNAMIC LISTBOX
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 |
DYNAMIC LISTBOX
May be
define A1 as low define A2 as high list box refers to =OFFSET(Sheet2!$B$1,low-1,0,high-low+1,1) "daphoenix" wrote in message ... 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 |
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 |
All times are GMT +1. The time now is 07:28 AM. |
Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com