PC Review


Reply
Thread Tools Rate Thread

Combobox questions

 
 
=?Utf-8?B?TWVraW5uaWs=?=
Guest
Posts: n/a
 
      3rd Nov 2007
I would like to know what events I should use or if I should use an event for
the following questions?

1)How to capture what the user input(types) into the combobox1 and see if it
matches any names in say sheet1 column 'A'. If it does then give combobox2
focus.

2)Populate combobox2's list with names that match the name the user typed
into combobox1 from sheet2 column 'B' and continue with the entry form input.
Sheet2 looks like this. So if the user typed "john" combobox2's list would
show red,blue,brown.
column A column B
john red
fred red
john blue
jack green
john brown

3)If the user selects one of the names from combobox1 list I would like it
to do the same as item #2 above.

column 'A' from both sheets match, they just store different data
 
Reply With Quote
 
 
 
 
Chip Pearson
Guest
Posts: n/a
 
      3rd Nov 2007
Try code for ComboBox1 like the following. Change the ranges A1:A10 to
whatever you need.

Private Sub ComboBox1_Change()
Dim S As String
Dim V As Variant
Dim R As Range

S = Me.ComboBox1.Text
V = Application.Match(S, Worksheets("Sheet1").Range("A1:A10"), 0)
If IsError(V) = False Then
With Me.ComboBox2
.Clear
For Each R In Worksheets("Sheet2").Range("A1:A10")
If R.Text = S Then
.AddItem R(1, 2)
End If
Next R
.SetFocus
If .ListCount > 0 Then
.ListIndex = 0
End If
End With
End If
End Sub


--
Cordially,
Chip Pearson
Microsoft MVP - Excel, 10 Years
Pearson Software Consulting
www.cpearson.com
(email on the web site)


"Mekinnik" <(E-Mail Removed)> wrote in message
news:FD586A0A-1E2C-46EA-A814-(E-Mail Removed)...
>I would like to know what events I should use or if I should use an event
>for
> the following questions?
>
> 1)How to capture what the user input(types) into the combobox1 and see if
> it
> matches any names in say sheet1 column 'A'. If it does then give combobox2
> focus.
>
> 2)Populate combobox2's list with names that match the name the user typed
> into combobox1 from sheet2 column 'B' and continue with the entry form
> input.
> Sheet2 looks like this. So if the user typed "john" combobox2's list would
> show red,blue,brown.
> column A column B
> john red
> fred red
> john blue
> jack green
> john brown
>
> 3)If the user selects one of the names from combobox1 list I would like it
> to do the same as item #2 above.
>
> column 'A' from both sheets match, they just store different data


 
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
MORE combobox questions =?Utf-8?B?Ti5G?= Microsoft Excel Programming 6 20th Jun 2007 01:16 AM
More combobox questions lc Microsoft Excel Programming 1 6th Sep 2005 06:12 PM
Questions About ComboBox =?Utf-8?B?Q2hhcGxhaW4gRG91Zw==?= Microsoft Excel Programming 3 25th Feb 2005 02:51 PM
ComboBox questions Mika M Microsoft VB .NET 2 25th Jan 2004 05:10 PM
more combobox questions . . . . Newbie Microsoft Access Form Coding 4 22nd Oct 2003 03:13 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 01:48 AM.