PC Review


Reply
Thread Tools Rate Thread

Autofilter by combobox selection

 
 
CBartman
Guest
Posts: n/a
 
      13th Oct 2009
Hi there,
I'm stuck...
Sheet 1 contains rows of customer information.
Sheet 2 contains rows of machine information (including customer
number)Userform combobox #1 selection will filter machines range by customer
acct number to show only that customer's machines(I got that working). Now I
want to popluate a second combobox with the list of that customers machines.

My Sheet 1 named range is "Customers"
My Sheet 2 named range is "Equipment"

Currently, without autofilter, combobox #2 shows ALL machines, for ALL
customers.
With combobox #1 autofiltering the records, I'm only getting the top
"consecutive" records (1 - 4) showing up in the second combobox, not ALL
machines for that customer.

How do I specify (respecify) the combobox data source once the records are
filtered?
 
Reply With Quote
 
 
 
 
AB
Guest
Posts: n/a
 
      14th Oct 2009
Might try to do something along these lines (code in the Userform
module):

Private Sub ComboBox1_AfterUpdate()
Populate_2ndCmbBx
End Sub

Private Sub Populate_2ndCmbBx()
Dim c As Range
Dim CstMshnCol As Integer'Col number holding the Machine names to
put in cbx 2.

CstMshnCol = 2
Me.ComboBox2.Clear 'Clear existing list

For Each c In Worksheets(Sheet2).Columns(CstMshnCol).Cells
If c.Row > 1 Then ' Assumes that 1st row holds headers and you
don't want _
header in the dropdown.
If c.Value = vbNullString Then Exit For ' You might want
to have differnt _
exit strategy - this one assumes that want to
stop adding _
items when you encounter the first empty cell
If Not c.EntireRow.Hidden Then'Checks that the row isn't
filterred out.
Me.ComboBox2.AddItem c.Value
End If
End If
Next c

End Sub




On Oct 13, 6:55*pm, CBartman <CBart...@discussions.microsoft.com>
wrote:
> Hi there,
> I'm stuck...
> Sheet 1 contains rows of customer information.
> Sheet 2 contains rows of machine information (including customer
> number)Userform combobox #1 selection will filter machines range by customer
> acct number to show only that customer's machines(I got that working). Now I
> want to popluate a second combobox with the list of that customers machines.
>
> My Sheet 1 named range is "Customers"
> My Sheet 2 named range is "Equipment"
>
> Currently, without autofilter, combobox #2 shows ALL machines, for ALL
> customers.
> With combobox #1 autofiltering the records, I'm only getting the top
> "consecutive" records (1 - 4) showing up in the second combobox, not ALL
> machines for that customer.
>
> How do I specify (respecify) the combobox data source once the records are
> filtered?


 
Reply With Quote
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
fill combobox depending on selection from another combobox Adam Francis Microsoft Excel Misc 2 24th Jul 2008 07:39 PM
Filter one combobox based on another combobox selection =?Utf-8?B?Y29uZnUtc2Vk?= Microsoft Access Forms 5 11th Jul 2007 12:39 PM
ComboBox.Items.Clear() causes the selection of Text inside the edit of the ComboBox Nomasnd Microsoft Dot NET Framework Forms 1 27th Sep 2006 06:32 PM
Combobox items determined by the selection in another combobox =?Utf-8?B?QWxlcmlvbg==?= Microsoft Excel Programming 2 13th Sep 2006 01:07 PM
Autofilter row selection ianripping Microsoft Excel Worksheet Functions 4 28th Nov 2003 10:34 AM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 12:16 AM.