Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 59
Default Userform with 2 Listboxes

Hello,
I would like to create a Userform for data input and on the Userform I need
two Listboxes. The first would be populated with data from the range "Depts"
and the second would populate to a range based on what is selected in the
first listbox.

I am able to do this on a normal worksheet using the Validation, but I would
like to do this on a Userform.

Is this possible? Thank you in advance.
Mike
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3,290
Default Userform with 2 Listboxes

Mike,

This should help...
http://support.microsoft.com/?kbid=213748
How to Populate One List Box Based on Another List Box

Jim Cone
San Francisco, USA


"Mike R." wrote in message
...
Hello,
I would like to create a Userform for data input and on the Userform I need
two Listboxes. The first would be populated with data from the range "Depts"
and the second would populate to a range based on what is selected in the
first listbox.

I am able to do this on a normal worksheet using the Validation, but I would
like to do this on a Userform.

Is this possible? Thank you in advance.
Mike

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 252
Default Userform with 2 Listboxes

Mike

In addition to Jim's suggestion you might want to try using the INDIRECT
function:

This example might be used for a make believe car dealer letting a customer
select first a car model and then a color for that particular model.

First, I used a list of Cars: Civic, Accord, Spirit etc. and named this
range: Cars
I named another cell: MyCar
I then used the Car models as headers for new Named Ranges: Civic, Accord...
These must be exact duplicates of the items in the Cars list.
Below each of these headers I made a list of available colors for each
model. These will vary per model.
I then created another Name ---InsertNameDefine ---typed CarColor in the
top box where the name goes. In the RefersTo box I typed: =INDIRECT(MyCar)
--with the equal sign.
I have done this with comboboxes rather that Listboxes but it should be the
same.
Create a UserForm with Combobox1 and Combobox2

In the Properties window I entered MyCar in the RowSource for Combobox1. In
the code for the userform I entered:

Private Sub ComboBox1_Change()
Range("MyCar") = Me.ComboBox1

'Fill the list for the next cbo
Me.ComboBox2.RowSource = "CarColor" 'This is the INDIRECT list
End Sub

Private Sub ComboBox2_Change()
Range("D20") = Me.ComboBox2 'Adjust D20 as needed
End Sub

--------------------------------
An advantage to using this Indirect method discussed in the KB article is
that you don't have to make a long Select Case set of code lines and access
to changing the list is more direct- a range on a worksheet.

Hope this helps

"Mike R." wrote:

Hello,
I would like to create a Userform for data input and on the Userform I need
two Listboxes. The first would be populated with data from the range "Depts"
and the second would populate to a range based on what is selected in the
first listbox.

I am able to do this on a normal worksheet using the Validation, but I would
like to do this on a Userform.

Is this possible? Thank you in advance.
Mike

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
Listboxes 2 Denise Excel Programming 2 June 8th 04 06:39 PM
Userform w/ Multiple listboxes that link miker1999[_13_] Excel Programming 1 April 27th 04 03:22 AM
Userform w/ Multiple listboxes that link miker1999[_12_] Excel Programming 0 April 20th 04 12:35 PM
Listboxes Lionel Fridjhon Excel Programming 0 April 5th 04 06:28 PM
Userform and reading multiple listboxes Bijl167[_6_] Excel Programming 3 December 8th 03 01:40 PM


All times are GMT +1. The time now is 02:08 PM.

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

About Us

"It's about Microsoft Excel"