Different drop down list depending on prev cell value

JasonRafton

New Member
Joined
Feb 1, 2023
Messages
11
Office Version
  1. 365
Platform
  1. Windows
Hi All,
An absolute newbie here. Trying to learn a new skill. I would like to have 2 different drop down lists in one column depending on what is selected in a previous cell.
In column D, if SUB is selected I would like a drop down list in Column K. If in column D, WIP is selected then I would like a different list in column K.
I know you guys will probably do this with your eyes closed but :( not me. Please be simple with your answers..... lol

1675231020972.png
 
Below is the code I have on my sheet.
I need to be able to manually enter a NAME in column 8 if necessary without an error code coming up.
How can I do this?



Private Sub Worksheet_Change(ByVal Target As Range)
If Target.Column <> 4 Then Exit Sub
If Target.Value = "SUB" Then
' Adjust with your Own choices in Formula1:
With Target.Offset(0, 8).Validation
.Delete
.Add Type:=xlValidateList, AlertStyle:=xlValidAlertStop, Operator:= _
xlBetween, Formula1:="KRUEGER,ROYANS,T/SALES,VAWDREY,VOLVO,BDS,HAMMAR"
End With
ElseIf Target.Value = "WIP" Then
With Target.Offset(0, 8).Validation
' Adjust with your Own choices in Formula1:
.Delete
.Add Type:=xlValidateList, AlertStyle:=xlValidAlertStop, Operator:= _
xlBetween, Formula1:="ALEX B,JYE P,LUKE K,BDS-ETHAN,BDS LACHLAN,OP-MATT,STT-TRAVIS,STT-ALEX,STT-ALF,STT-NICK S,STT-TIM,TSS-GERRY,TSS-TRENTE"
End With
ElseIf Target.Value = "OS" Then
With Target.Offset(0, 8).Validation
' Adjust with your Own choices in Formula1:
.Delete
.Add Type:=xlValidateList, AlertStyle:=xlValidAlertStop, Operator:= _
xlBetween, Formula1:="ALEX B,JYE P,LUKE K,BDS-ETHAN,BDS LACHLAN,OP-MATT,STT-TRAVIS,STT-ALEX,STT-ALF,STT-NICK S,STT-TIM,TSS-GERRY,TSS-TRENTE"
End With
End If
End Sub
 
Upvote 0

Excel Facts

Test for Multiple Conditions in IF?
Use AND(test, test, test, test) or OR(test, test, test, ...) as the logical_test argument of IF.
Hi,
Sorry ... but just tested again your macro and it is working as expected ... you can input a name in Column L (y)
 
Upvote 0
Hi again,

Looks like you mean you want to allow the user to Input a Name NOT Present in the Data Validation List

VBA Code:
Private Sub Worksheet_Change(ByVal Target As Range)
' Adjusted to Allow User to Input a Name NOT Present in the Data Validation List '''''''''
If Target.Column <> 4 Then Exit Sub
    If Target.Value = "SUB" Then
    ' Adjust with your Own choices in Formula1
        With Target.Offset(0, 8).Validation
            .Delete
            .Add Type:=xlValidateList, AlertStyle:=xlValidAlertInformation, Operator:= _
            xlBetween, Formula1:="KRUEGER,ROYANS,T/SALES,VAWDREY,VOLVO,BDS,HAMMAR"
        End With
    ElseIf Target.Value = "WIP" Then
        With Target.Offset(0, 8).Validation
            .Delete
            .Add Type:=xlValidateList, AlertStyle:=xlValidAlertInformation, Operator:= _
            xlBetween, Formula1:="ALEX B,JYE P,LUKE K,BDS-ETHAN,BDS LACHLAN,OP-MATT,STT-TRAVIS,STT-ALEX,STT-ALF,STT-NICK S,STT-TIM,TSS-GERRY,TSS-TRENTE"
        End With
    ElseIf Target.Value = "OS" Then
        With Target.Offset(0, 8).Validation
            .Delete
            .Add Type:=xlValidateList, AlertStyle:=xlValidAlertInformation, Operator:= _
            xlBetween, Formula1:="ALEX B,JYE P,LUKE K,BDS-ETHAN,BDS LACHLAN,OP-MATT,STT-TRAVIS,STT-ALEX,STT-ALF,STT-NICK S,STT-TIM,TSS-GERRY,TSS-TRENTE"
        End With
    End If
End Sub
 
Upvote 0
Hi again,

Looks like you mean you want to allow the user to Input a Name NOT Present in the Data Validation List

VBA Code:
Private Sub Worksheet_Change(ByVal Target As Range)
' Adjusted to Allow User to Input a Name NOT Present in the Data Validation List '''''''''
If Target.Column <> 4 Then Exit Sub
    If Target.Value = "SUB" Then
    ' Adjust with your Own choices in Formula1
        With Target.Offset(0, 8).Validation
            .Delete
            .Add Type:=xlValidateList, AlertStyle:=xlValidAlertInformation, Operator:= _
            xlBetween, Formula1:="KRUEGER,ROYANS,T/SALES,VAWDREY,VOLVO,BDS,HAMMAR"
        End With
    ElseIf Target.Value = "WIP" Then
        With Target.Offset(0, 8).Validation
            .Delete
            .Add Type:=xlValidateList, AlertStyle:=xlValidAlertInformation, Operator:= _
            xlBetween, Formula1:="ALEX B,JYE P,LUKE K,BDS-ETHAN,BDS LACHLAN,OP-MATT,STT-TRAVIS,STT-ALEX,STT-ALF,STT-NICK S,STT-TIM,TSS-GERRY,TSS-TRENTE"
        End With
    ElseIf Target.Value = "OS" Then
        With Target.Offset(0, 8).Validation
            .Delete
            .Add Type:=xlValidateList, AlertStyle:=xlValidAlertInformation, Operator:= _
            xlBetween, Formula1:="ALEX B,JYE P,LUKE K,BDS-ETHAN,BDS LACHLAN,OP-MATT,STT-TRAVIS,STT-ALEX,STT-ALF,STT-NICK S,STT-TIM,TSS-GERRY,TSS-TRENTE"
        End With
    End If
End Sub
That is correct
 
Upvote 0

Forum statistics

Threads
1,215,025
Messages
6,122,731
Members
449,093
Latest member
Mnur

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