Userform to show only specific data in combobox dependant on other combobox selection

ipbr21054

Well-known Member
Joined
Nov 16, 2010
Messages
5,736
Office Version
  1. 2007
Platform
  1. Windows
Hi,
I have a userform with various comboboxes.
Ther 2 comboboxes in question are as follows.

ComboBox3 of which is MAKE comprising of "HONDA" "KAWASAKI" "YAMAHA" & are the values in drop down list
This is Table 1

ComboBox8 of which is ORIGINAL PART NUMBERS comprising of ALL part number for all the makes mentioned above currently say 20 of them
Currently this is Table 6

So example of what i would like to do.
If HONDA is selected in ComboBox3 then only show the honda part numbers in ComboBox8

So i assume that i need new tables for each make so i have now done that.
HONDA is Table 9
KAWASAKI is Table 10
YAMAHA is Table 11

Later i will be adding more but for now can you advise how i write the code for ComboBox8

Example
If HONDA is selected only show Table 9 results
ELSE
If KAWASAKI is selected only show Table 10 result
ELSE
If YAMAHA is selected only show Table 11 result


Many thanks
 
Pictures do not really help - as said, you know code works so clearly something is different in a transfer to your main workbook
- Just need to keep checking each table & worksheet name to ensure all match & hopefully, you will find the culprit causing the error

Dave
 
Upvote 0

Excel Facts

Is there a shortcut key for strikethrough?
Ctrl+S is used for Save. Ctrl+5 is used for Strikethrough. Why Ctrl+5? When you use hashmarks to count |||| is 4, strike through to mean 5.
Does KAWASAKI & YAMAHA also fail for you
The photos were to show the name / spelling etc of tabs & in the code of which are the same.
 
Upvote 0
There are only 2 works sheets
Parts Table & Model Table
I originally had HONDA KAWASAKI SUZUKI YAMAHA
But i now ive added to it so HONDA KAWASAKI SUZUKI YAMAHA APRILLIA PIAGGIO

I run the code again & only HANDA & SUZUKI work

I cant make that many spelling mistakes.
Please advise if ALL work for you or does KAWASAKI & YAMAHA also fail
Thanks,
 
Upvote 0
I was expecting in your main workbook to have more than one entry for each table - with a single entry, the value returned is not an array that the List property requires

See if this update resolves

VBA Code:
Private Sub ComboBox3_Change()
    Dim wsPartsTables          As Worksheet
    Dim wsModelTables          As Worksheet
    Dim tbl(1 To 2)            As ListObject
    Dim arr(1 To 2)            As Variant
    Dim whichtable             As String
     
    'make
    whichtable = Me.ComboBox3.Value
    If Len(whichtable) = 0 Then Exit Sub
 
      'set object variable to combobox parts tables worksheet
    Set wsPartsTables = ThisWorkbook.Worksheets("Parts Tables")
 
     'set object variable to combobox model tables worksheet
    Set wsModelTables = ThisWorkbook.Worksheets("Model Tables")
 
    Set tbl(1) = wsPartsTables.ListObjects(whichtable & "Table")
    arr(1) = tbl(1).DataBodyRange.Value: If Not IsArray(arr(1)) Then arr(1) = Array(arr(1))
 
    Set tbl(2) = wsModelTables.ListObjects(whichtable & "Model")
    arr(2) = tbl(2).DataBodyRange.Value: If Not IsArray(arr(2)) Then arr(1) = Array(arr(2))
 
    'parts
     With Me.ComboBox8
        .RowSource = ""
        .List = arr(1)
     End With
  
     'models
     With Me.ComboBox4
        .RowSource = ""
        .List = arr(2)
     End With
 
End Sub
 
Upvote 0
Solution

Forum statistics

Threads
1,223,888
Messages
6,175,217
Members
452,619
Latest member
Shiv1198

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