Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
2 comboboxes working 2gether
Teams...............BX#1.....BX#2...etc....etc.... .etc
BX#1...................AA.......AW BX#2...................CB.......CR BX#3...................GB.......ET BX Sites...............HC.......JV BX 149.................JH.......MP MH#1...................LJ.......NG MH#2...................LR......TS MH Sites...............MP.....TP I need help making 2 comboboxes work together in an "userform". I don't even know how to start with the VBA code. I can populate the 1st combobox with the team list... but I need that when the user selects a team, that the corresponding information is populated in the 2nd combobox. For example, if the user selects "BX#1", then the BX#1 list is populated in the 2nd combobox. If user selects "MH Sites" then the MH Sites list is populated and so on. There are 24 different list depending on 1st selection. Please experts, help me! - Larry - VBA Amateur --- Message posted from http://www.ExcelForum.com/ |
#2
Posted to microsoft.public.excel.programming
|
|||
|
|||
2 comboboxes working 2gether
|
#3
Posted to microsoft.public.excel.programming
|
|||
|
|||
2 comboboxes working 2gether
|
#4
Posted to microsoft.public.excel.programming
|
|||
|
|||
2 comboboxes working 2gether
How about something like:
Option Explicit Dim blkProc As Boolean Private Sub ComboBox1_Change() Dim FoundCell As Range Dim myRng As Range blkProc = True Me.ComboBox2.Clear blkProc = False If Me.ComboBox1.ListIndex = -1 Then Exit Sub Else With Worksheets("sheet1") With .Rows(1) Set FoundCell = .Cells.Find(what:=Me.ComboBox1.Value, _ after:=.Cells(.Cells.Count), _ LookIn:=xlValues, lookat:=xlWhole, _ MatchCase:=False) If FoundCell Is Nothing Then MsgBox "Design error!" & vbLf & "please call Larry @xxxx" Exit Sub End If End With Set myRng = .Range(.Cells(2, FoundCell.Column), _ .Cells(.Rows.Count, FoundCell.Column).End(xlUp)) Me.ComboBox2.List = myRng.Value End With End If End Sub Private Sub ComboBox2_Change() If blkProc Then Exit Sub MsgBox "hi" End Sub Private Sub UserForm_Initialize() Dim myRng As Range With Worksheets("Sheet1") Set myRng = .Range("a2", .Cells(.Rows.Count, "A").End(xlUp)) End With Me.ComboBox1.List = myRng.Value End Sub "nrage21 <" wrote: Help - Larry - VBA Amateur --- Message posted from http://www.ExcelForum.com/ -- Dave Peterson |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
comboboxes | Excel Discussion (Misc queries) | |||
Comboboxes | New Users to Excel | |||
Need help with ComboBoxes. | New Users to Excel | |||
Comboboxes | Excel Programming | |||
Comboboxes | Excel Programming |