Populate Data Validation w/ corresponding values

BrianExcel

Well-known Member
Joined
Apr 21, 2010
Messages
975
This is complicated (I think) so bare with me...

In Column C are part numbers
In column D is a supplier name

Column C's part numbers vary in qty. In other words, one vendor name may appear 25 times in column D because they have 25 part numbers available. But another vendor only appears 5 times because they only have 5 parts.

Right now, a combo box is populated with the vendor name. What I need, is when that vendor name is chosen (the combo box corresponds to the vendor names in Column D) I need ALL part numbers associated with that vendor to populate into a cell using data validation.

Right now I am using the following code, which hard codes specific words into the data validation, but I need to dynamically change the options based on the name I select in the drop down box above.

Does this make sense? Feel free to ask more clarifying questions if needed.

Code:
Public Sub DropDownCode()
Dim i       As Long, _
    LR      As Long, _
    Choices As String
    
With Application
    .ScreenUpdating = False
    .Calculation = xlCalculationManual
    .EnableEvents = False
End With

LR = Range("D" & Rows.Count).End(xlUp).Row
    Choices = "Cookies, Apples, Choices"
For i = 12 To LR Step 4
    With Range("D" & i).Validation
        .Delete
        .Add Type:=xlValidateList, _
        AlertStyle:=xlValidAlertStop, Operator:= _
        xlBetween, Formula1:=Choices
        .IgnoreBlank = True
        .InCellDropdown = True
        .InputTitle = ""
        .ErrorTitle = ""
        .InputMessage = ""
        .ErrorMessage = ""
        .ShowInput = True
        .ShowError = True
    End With
Next i

With Application
    .ScreenUpdating = True
    .Calculation = xlCalculationAutomatic
    .EnableEvents = True
End With
End Sub


Thanks for any help in advance!
 

Excel Facts

Pivot Table Drill Down
Double-click any number in a pivot table to create a new report showing all detail rows that make up that number
You could filter Column D by the supplier chosen, Then copy the visible items to a hidden column and then use that column to apply the validation for the 2nd drop down.
 
Upvote 0

Forum statistics

Threads
1,225,071
Messages
6,182,687
Members
453,132
Latest member
nsnodgrass73

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