Home |
Search |
Today's Posts |
|
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
Row Source based on a filtered list
Hi first post here.
I have a problem creating a row source for a combo box. I have a worksheet that has 3 columns: "Code", "Type", "Description" On my form there are 2 combo boxes. Combo box selects the "Type" What I want the second combo box to do is create its list from the records on the worksheet where the rcords are of the "type" selected by the first box. (Same as AuotFilter works) Any help greatly appreciated, but take it easy i'm a newbie to vba TIA |
#2
Posted to microsoft.public.excel.programming
|
|||
|
|||
Row Source based on a filtered list
Just loop through the range and where the entry in the second column equals
the selected type, use additem to add the data to the second combobox. -- Regards, Tom Ogilvy "easy" wrote in message ... Hi first post here. I have a problem creating a row source for a combo box. I have a worksheet that has 3 columns: "Code", "Type", "Description" On my form there are 2 combo boxes. Combo box selects the "Type" What I want the second combo box to do is create its list from the records on the worksheet where the rcords are of the "type" selected by the first box. (Same as AuotFilter works) Any help greatly appreciated, but take it easy i'm a newbie to vba TIA |
#3
Posted to microsoft.public.excel.programming
|
|||
|
|||
Row Source based on a filtered list
Thanks for the reply Tom, at least I know it can be done!
But as a newbie I got lost after "just loop through..." Any chance of giving an example of code? or where to look for examples "Tom Ogilvy" wrote: Just loop through the range and where the entry in the second column equals the selected type, use additem to add the data to the second combobox. -- Regards, Tom Ogilvy "easy" wrote in message ... Hi first post here. I have a problem creating a row source for a combo box. I have a worksheet that has 3 columns: "Code", "Type", "Description" On my form there are 2 combo boxes. Combo box selects the "Type" What I want the second combo box to do is create its list from the records on the worksheet where the rcords are of the "type" selected by the first box. (Same as AuotFilter works) Any help greatly appreciated, but take it easy i'm a newbie to vba TIA |
#4
Posted to microsoft.public.excel.programming
|
|||
|
|||
Row Source based on a filtered list
I put a couple of comboboxes on a userform and used this:
Option Explicit Dim BlkProc As Boolean Private Sub ComboBox1_Change() Dim myCell As Range Dim myRng As Range With Worksheets("sheet1") Set myRng = .Range("a2", .Cells(.Rows.Count, "A").End(xlUp)) End With BlkProc = True Me.ComboBox2.Clear If Me.ComboBox1.Value < 0 Then 'do nothing Else For Each myCell In myRng.Cells If LCase(myCell.Value) = LCase(Me.ComboBox1.Value) Then Me.ComboBox2.AddItem myCell.Offset(0, 1).Value End If Next myCell End If BlkProc = False End Sub Private Sub ComboBox2_Change() If BlkProc = True Then Exit Sub 'any other code you want here End Sub Private Sub UserForm_Initialize() With Me.ComboBox1 .Style = fmStyleDropDownList .AddItem "A" .AddItem "B" .AddItem "C" End With End Sub easy wrote: Thanks for the reply Tom, at least I know it can be done! But as a newbie I got lost after "just loop through..." Any chance of giving an example of code? or where to look for examples "Tom Ogilvy" wrote: Just loop through the range and where the entry in the second column equals the selected type, use additem to add the data to the second combobox. -- Regards, Tom Ogilvy "easy" wrote in message ... Hi first post here. I have a problem creating a row source for a combo box. I have a worksheet that has 3 columns: "Code", "Type", "Description" On my form there are 2 combo boxes. Combo box selects the "Type" What I want the second combo box to do is create its list from the records on the worksheet where the rcords are of the "type" selected by the first box. (Same as AuotFilter works) Any help greatly appreciated, but take it easy i'm a newbie to vba TIA -- Dave Peterson |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Return filtered values into report worksheet based on filtered valueon the data worksheet | Excel Worksheet Functions | |||
Pivot Tables Based on Filtered Data | Excel Worksheet Functions | |||
How to create one table based on filtered data from various worksh | Excel Discussion (Misc queries) | |||
Graph based on Filtered results | Excel Discussion (Misc queries) | |||
traversing through a filtered range based on another filtered range | Excel Programming |