Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 18
Default 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
  #2   Report Post  
Posted to microsoft.public.excel.programming
KC KC is offline
external usenet poster
 
Posts: 55
Default 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



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,069
Default 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

Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Dynamic link with 2 dependent listbox? Cam Excel Discussion (Misc queries) 0 April 8th 09 06:51 PM
dynamic fill of listbox - need help gonger Excel Programming 6 May 25th 06 07:16 PM
Write a Listbox list to a dynamic range blayne Excel Programming 5 November 29th 05 05:35 PM
Dynamic Multi Column ListBox Ronbo Excel Programming 3 January 11th 05 07:59 PM
Making a Dynamic List in Listbox MikeM[_4_] Excel Programming 2 December 16th 03 04:16 PM


All times are GMT +1. The time now is 09:49 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"