Dropdown Value List with Variable Items based on selected value of another field

NWPhotoExplorer

New Member
Joined
Jan 19, 2021
Messages
34
Office Version
  1. 365
Platform
  1. Windows
  2. MacOS
Hello all,

I am trying to figure out how to make a dropdown list that will display only certain items based on the selection of a field. Right now, I have a "name" field in column G, a "type" field in column H. I want the dropdown in column I.

Basically, how I would like it to work is that someone types in the name in column G. This is a 10 digit name. First 5 are letters and the last 5 are numbers. Then they select the type, either 1x1 or 1x2. Column I would then show either 1 or 2 items based on if it was a 1x1 or 1x2.

If it was a 1x1, it would take the left 9 and add a "1" in the last place. If it was a 1x2, it would take the left 9 and add either a "1" or a "3" to the last position.

I cannot figure out how to write something that would accomplish this for me. Here is an example of the output I am trying to achieve.

FLW REQUEST.xlsx
GHI
1Node Housing Name1x1 or 1x2RPD NAME
2CAADD999001x1CAADD99901
3CAADD999001x2CAADD99901
4CAADD999001x2CAADD99903
Sheet1


I hope I have explained this well enough.

Thanks in advance!
 

Excel Facts

What does custom number format of ;;; mean?
Three semi-colons will hide the value in the cell. Although most people use white font instead.
Not sure why you want a drop down, but you can get the (somewhat) expected results with a nested IF

I say somewhat because I don't what what condition your data would need to meet in order to differentiate when to put a "1" or "3" at the end of the string if you select 1x2.


=IF(H2 = "1x1", LEFT(G2, 9) & "1", IF(H2 ="1x2", LEFT(G2,9) & "3", "Error")
 
Upvote 0
Not sure why you want a drop down, but you can get the (somewhat) expected results with a nested IF

I say somewhat because I don't what what condition your data would need to meet in order to differentiate when to put a "1" or "3" at the end of the string if you select 1x2.


=IF(H2 = "1x1", LEFT(G2, 9) & "1", IF(H2 ="1x2", LEFT(G2,9) & "3", "Error")
I can't think of a better way to achieve this, so that is why I posted the question hoping someone else could come up with something. I need something, like a drop-down, because when the node is a 1x2, it will have the "1" RPD name, but it could have the second piece of equipment in there which I would need another line to show the "3" name as then i would have to show the other fields with the "C" and "D" names.
 

Attachments

  • example.png
    example.png
    107.6 KB · Views: 6
Upvote 0
Gotcha. Here's the VBA Code

VBA Code:
Private Sub Worksheet_Change(ByVal Target As Range)
    If Target.Column = 8 Then
        Range("I" & Target.Row).Validation.Delete
        
        If Target.Value = "1x1" Then
            Range("I" & Target.Row).Validation.Add Type:=xlValidateList, AlertStyle:=xlValidAlertStop, _
            Formula1:=VBA.Left(Target.Offset(0, -1), 9) & "1"
        ElseIf Target.Value = "1x2" Then
            Range("I" & Target.Row).Validation.Add Type:=xlValidateList, AlertStyle:=xlValidAlertStop, _
            Formula1:=VBA.Left(Target.Offset(0, -1), 9) & "1" & "," & _
            VBA.Left(Target.Offset(0, -1), 9) & "3"
        Else
            Range("I" & Target.Row).Validation.Delete
        End If
    End If
End Sub
 
Upvote 0

Forum statistics

Threads
1,216,920
Messages
6,133,466
Members
449,808
Latest member
BoredSean

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