Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
AJ AJ is offline
external usenet poster
 
Posts: 99
Default Combination of 2 combo boxes to populate 3rd

Thank you for helping. I am used to working with Access, but am trying to
work on a project where I'm required to use Excel programming. If you would
make some notes in your programming, that would be very helpful for me to
learn.

This is where I need some help, and I'll draw it out since I think it will
explain it better:

Level Age 8 Age 9 Age 10
Level 1 Coach A&B Coach B&C Coach D&E
Level 2 Coach F&G Coach H&I Coach J&K

I would like to make 3 combo boxes, the first of which would ask for a
child's level (cboLevel), the second would prompt for age (cboAge), and the
third combo box would display a choice of coach (cboCoach) based on the
answers from the prior two combo boxes.

Thanks in advance for your help.
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,163
Default Combination of 2 combo boxes to populate 3rd

This can be done: you need to set up data ranges somewhere (maybe on a hidden
sheet) with each set of selections listed together, e.g.

Coach A Coach D
Coach B Coach E ...

Coach B ....
Coach C

The code below should work, substituting in the proper ranges; I am sure it
could be simplified, too, if you lay out your coaches lists smartly and use
some math to match the range to the selections in the first 2 comboboxes...

Private Sub cboAge_Change()

Select Case Range(LinkedCellforAge)
Case 8
If Range(LinkedCellforLevel) = "Level 1" Then cboCoach.ListFillRange =
Range(CoachesRange1)
If Range(LinkedCellforLevel) = "Level 2" Then cboCoach.ListFillRange =
Range(CoachesRange2)
Case 9
If Range(LinkedCellforLevel) = "Level 1" Then cboCoach.ListFillRange =
Range(CoachesRange3)
If Range(LinkedCellforLevel) = "Level 2" Then cboCoach.ListFillRange =
Range(CoachesRange4)
Case 10
If Range(LinkedCellforLevel) = "Level 1" Then cboCoach.ListFillRange =
Range(CoachesRange5)
If Range(LinkedCellforLevel) = "Level 2" Then cboCoach.ListFillRange =
Range(CoachesRange5)
End Select

End Sub

Private Sub cboLevel_Change()

Call cboAge_Change

End Sub



"AJ" wrote:

Thank you for helping. I am used to working with Access, but am trying to
work on a project where I'm required to use Excel programming. If you would
make some notes in your programming, that would be very helpful for me to
learn.

This is where I need some help, and I'll draw it out since I think it will
explain it better:

Level Age 8 Age 9 Age 10
Level 1 Coach A&B Coach B&C Coach D&E
Level 2 Coach F&G Coach H&I Coach J&K

I would like to make 3 combo boxes, the first of which would ask for a
child's level (cboLevel), the second would prompt for age (cboAge), and the
third combo box would display a choice of coach (cboCoach) based on the
answers from the prior two combo boxes.

Thanks in advance for your help.

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 271
Default Combination of 2 combo boxes to populate 3rd

"K Dales" wrote:

This can be done: you need to set up data ranges <snip

The code below should work, substituting in the proper ranges...


A few additional points--This assumes we're on a worksheet using the ActiveX
ComboBoxes (the ones in the "Control Toolbox" toolbar, not the one on the
Forms toolbar.) If these ComboBoxes are on a form, the property you'd use to
populate them would be RowSource instead of ListFillRange.

And given the 'business constraints' of the application, any time you change
one of the first two comboBoxes, the entry in the third will likely be
invalid. So you should probably clear the cboCoach comboBox any time the
cboAge or cboLevel comboBox changes. But don't use the Clear method--that
will result in a run-time error with a helpful explanation like: "Run-time
error. -2310293840921834123." What that's trying to say is that you can't
Clear a ComboBox that has something in the ListFillRange/RowSource property.
You have to do something like this (clearing cboCoach when cboLevel changes.
Do something similar for cboAge.)

Private Sub cboLevel_Change()
cboCoach.ListFillRange = ""
cboCoach.Value = ""
End Sub

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
Getting Combo boxes to change options based on other Combo boxes. Ancient Wolf New Users to Excel 1 March 27th 09 06:29 PM
Best way to populate worksheet from 2 combo boxes jswasson Excel Worksheet Functions 0 July 7th 06 01:21 PM
Selecting subsets using combo boxes or list boxes CLamar Excel Discussion (Misc queries) 0 June 1st 06 07:43 PM
Questions on combo boxes and list boxes. Marc New Users to Excel 1 March 14th 06 09:40 AM
Combo Boxes and Tick Boxes turner2000 Excel Programming 0 September 28th 04 10:01 PM


All times are GMT +1. The time now is 05:36 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"