VLOOKUP or Advanced Filter in vba for my userform

herb1

New Member
Joined
Apr 18, 2016
Messages
3
Hi All,

I'm trying to develop a Userform to capture defects detected in an electronic manufacturing plant.
Userform (below):

jafcMoB.png

jafcMoB

jafcMoB


I have managed to set up dependent combo boxes that helps to identify the customer and part number.
I would like the Assembly Description to be populated in a textbox of the userform.

Here is a sample of the Excel table that I'm using to populate the combo boxes and would like to populate the Assembly Description based on the Customer and Assembly No. chosen.
Bear in mind that the Assembly Descriptions are not in a single column but in various columns, based on the Customer selected and based on the row selected for the Assembly No.

1bGjFpd.png


For example, I would like to have the textbox for Assembly Description populated (as such):
Customer Assembly No. Assembly Description
Mr Krabs MK-006 Sunglasses

I need help here 'cos I'm lost for the vba code.
I don't know whether I should use VLOOKUP or ADVANCED FILTER.
 

Excel Facts

Excel Can Read to You
Customize Quick Access Toolbar. From All Commands, add Speak Cells or Speak Cells on Enter to QAT. Select cells. Press Speak Cells.
Change data in red by your information.

If you need help tell me the name of your controls.


Also put the code to use to load the combos.


Try this

Code:
Private Sub ComboCustomer_Change()
    [COLOR=#ff0000]ComboNo[/COLOR].Value = ""
    [COLOR=#ff0000]TextDes[/COLOR].Value = ""
    If [COLOR=#ff0000]ComboCustomer[/COLOR].ListIndex = -1 Then Exit Sub
End Sub


Private Sub [COLOR=#ff0000]ComboNo[/COLOR]_Change()
    [COLOR=#ff0000]TextDes[/COLOR].Value = ""
    If [COLOR=#ff0000]ComboNo[/COLOR].ListIndex = -1 Then Exit Sub
    If [COLOR=#ff0000]ComboNo[/COLOR].Value = "" Then Exit Sub
    Set b = Sheets("[COLOR=#ff0000]Sheet1[/COLOR]").Rows(1).Find([COLOR=#ff0000]ComboCustomer[/COLOR], LookIn:=xlValues, lookat:=xlWhole)
    If Not b Is Nothing Then
        col = b.Column
        Set c = Sheets("[COLOR=#ff0000]Sheet1[/COLOR]").Columns(col).Find([COLOR=#ff0000]ComboNo[/COLOR], LookIn:=xlValues, lookat:=xlWhole)
        If Not c Is Nothing Then
            [COLOR=#ff0000]TextDes[/COLOR].Value = c.Offset(0, 1).Value
        End If
    End If
End Sub
 
Upvote 0

Forum statistics

Threads
1,223,894
Messages
6,175,252
Members
452,623
Latest member
Techenthusiast

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