A Microsoft Excel forum. ExcelBanter

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

Go Back   Home » ExcelBanter forum » Excel Newsgroups » Excel Programming
Site Map Home Register Authors List Search Today's Posts Mark Forums Read Web Partners

Combobox items based on choice in previous combobox



 
 
Thread Tools Display Modes
  #1  
Old August 2nd 11, 03:52 AM posted to microsoft.public.excel.programming
Slim Slender[_3_]
external usenet poster
 
Posts: 38
Default Combobox items based on choice in previous combobox

I think I'm on to something here. I'm just not getting the code right.

Num Comment
1 this is the comment for the first example of number 1.
1 This is the second comment for number one.
2 This is the only comment for nymber 2.
3 Comment for number 3
5 First comment for number 5
5 Second comment for number 5.
5 Third comment for number 5.
6 Only comment for number 6.
7 One of two comments for number 7.
7 The other comment for number 7.

I have a table or range that looks like above. Notice repeated numbers
in first column.
I use a little procedure to get only the unique values in Num column
to populate a combobox.
The next thing would be to select one of those numbers, 5 for example,
and populate a combobox
with only the three comments associated with that number. It occurred
to me that defining and then adding items selectively, based on
criterion might be the way. Below is my attempt but it doesn't quite
work.

Private Sub ComboBox5_Change()

Dim rng As Range, i As Long
Dim SelectedComments As New Collection, Item

For i = 1 To
Worksheets("Sheet2").Range("ReferenceGuide").Rows. Count
Set rng = Worksheets("Sheet2").Cells(i, 2)
If rng.Offset(0, -1).Value = ComboBox5.Value Then
SelectedComments.Add rng.Value, CStr(rng.Value)
End If
Next

For Each Item In SelectedComments
UserForm1.ComboBox6.AddItem Item
Next Item
End Sub
Ads
 




Thread Tools
Display Modes

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

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Numeric Value of Choice in Combobox WLMPilot Excel Programming 2 January 10th 08 09:31 PM
Create a RowSource Depending on ComboBox Choice Blobbies Excel Discussion (Misc queries) 3 November 18th 07 01:22 AM
Combobox items determined by the selection in another combobox Alerion Excel Programming 2 September 13th 06 01:07 PM
Combobox options based on the input of another combobox afmullane[_5_] Excel Programming 1 May 3rd 06 01:44 PM
combobox loses first choice Dave Excel Programming 1 October 20th 04 06:15 PM


All times are GMT +1. The time now is 05:27 AM.


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