PDA

View Full Version : Displaying data from worksheet range in listbox



AlvinChaand
08-27-2008, 03:07 PM
I have 2 searchboxes that enables user to pick from a combobox.
If user Select COUNTRY= MALAYSIA AND STATE =IPOH
I want the places of interest displayed in the listbox from the data in my worksheet.
How do i get the data from the worksheet to be displayed in the listbox?
Also how do i ensure that the data in the listbox changes when the user searches for Country=Canada STATE=toronto etc?


Please help...any help will e greatly appreciated
Thank you! :) * i m a beginner so please guide me along.

akanchu
08-30-2008, 08:26 PM
Hi,
I am not sure if I got ur question right.
Here is what u could try.
Make country as sheet names, and POI as column.
so for state 1, fill the POI in column A
so for state 2, fill the POI in column B.. .. and so on.

This is what I tried on a sheet I added a 1combo has the state 1, 2 and 3. You can name whatever you want.
1 listbox to show the result.

Filled column (states) A with value POI with a1 to a10 ; state b with b1 to b10 and state C with vlaue c1 to c10.

On change event of combo, i used this.


ListBox1.Clear
If ComboBox1.Value = "" Then Exit Sub
For i = 1 To 10
n1 = ComboBox1.ListIndex + 1
str1 = Cells(i, n1)
ListBox1.AddItem (str1)

Next i




This fills the list box with values of the column you choose.
You might have to modify the code to include the sheet name.

Hope this helps.

AlvinChaand
09-19-2008, 03:28 AM
Hello, i did help :) thank u i got another problem now....

AlvinChaand
09-19-2008, 03:58 AM
Hello i think i shall retype my question as the previous one was a little misleading

Been trying to work on this for quite sometime now... i'm a newbie so really have no foundation in this....:banghead:

on this userform, i have 2 comboboxes, a search button and a listbox
Combobox1 is for user to select the country
combobox2 is for user to select the city
when search is clicked,
the listbox is populated with data according to the user's search criteria
How do i go about doing this?:dunno

Thank u in advance for any help rendered.
I appreciate ur time and patience.:friends:

Bob Phillips
09-19-2008, 04:45 AM
The question is still totally unclear. If you have two comboboxes for country and city, you already have th user's SELECTION criteria, why do you need to put those items in a listbox?