ComboBox String

DAWG2006

Board Regular
Joined
Feb 15, 2009
Messages
86
Good evening everyone,
What I am trying to accomplish is to have a ComboBox (we will call this ComboBox1) populate a list of data. When one of those data points are selected using ComboBox1 I need it to populate and additional list of data points (different info) in ComboBox2.

In other words, I need the ComboBox to act similar to the vlookup function however instead of a single point I need the ComboBox to produce a list. Below is the code I have started:

Code:
Private Sub UserForm_Initialize()
 Dim cPart As Range
 Dim cLoc As Range
 Dim ws As Worksheet
 Set ws = Worksheets("Catalog")
 
 For Each cPart In ws.Range("type")
  With Me.ComboBox1
      .AddItem cPart.Value
      .List(.ListCount - 1, 1) = cPart.Offset(0, 1).Value
  End With
 Next cPart

End Sub

I have not added ComboBox2 in the code because of the unknown coding for what is required.

Thank you for the assistance in advance and if you need any additional information to fix my problem please ask.

DAWG2006
 

Excel Facts

Square and cube roots
The =SQRT(25) is a square root. For a cube root, use =125^(1/3). For a fourth root, use =625^(1/4).
How is the data for the 2nd combobox arranged?

How can the data for it be recognised/found based on the selection in the 1st combobox?
 
Upvote 0
What I have is 15 worksheets that are broken down by 15 names. Each worksheet has Column A as product names, and Column B as product codes. I would like ComboBox1 to be selectable of one of the 15 worksheet names, ComboBox2 listing the names from the corresponding worksheet, and then a text box auto filling with the corresponding column B information (i.e.; Worksheet3 = Cell A3 = Cell B3) in the respective order.

I hope this helps
 
Upvote 0
Sorry for not getting back to you - I must have missed the notification.

Anyway, are the 15 worksheets the only ones in the workbook or are they easily identifiable by something, eg name.

Or even better is their a list of their names.

We need one or the other to populate the first combobox.

Once that's done it should be straightforward to do the rest.

For example to populate the 2nd combobox:
Code:
Private Sub ComboBox1_Change()
Dim wsName As Range
Dim rngItems As Range
Dim LastRow As Long
 
   If ComboBox1.ListIndex<>-1 Then
 
      Set wsName = Worksheets(ComboBox1.Value)
 
      LastRow = wsName.Range("A"& Rows.Count).End(xlUp).Row
 
      ' change A1 to A2 if there is a header
      Set rngItems = Worksheets(ComboBox1.Value).Range("A1:A" & LastRow)
 
      ComboBox2.List = rngItems.Value
 
   End If
 
End Sub
 
Upvote 0

Forum statistics

Threads
1,224,597
Messages
6,179,813
Members
452,945
Latest member
Bib195

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top