Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35,218
Default 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
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
Return filtered values into report worksheet based on filtered valueon the data worksheet dicko1 Excel Worksheet Functions 1 April 21st 09 12:27 AM
Pivot Tables Based on Filtered Data Michael[_2_] Excel Worksheet Functions 1 September 22nd 08 10:21 PM
How to create one table based on filtered data from various worksh Annie Excel Discussion (Misc queries) 1 January 6th 06 05:58 PM
Graph based on Filtered results Steve Excel Discussion (Misc queries) 0 March 30th 05 04:59 PM
traversing through a filtered range based on another filtered range zestpt[_4_] Excel Programming 4 July 12th 04 06:37 PM


All times are GMT +1. The time now is 09:57 PM.

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

About Us

"It's about Microsoft Excel"