Sep 10 2023 06:27 AM
I have 2 drop down list on one excel sheet columns A and B. I would like to know if it is possible to either lock or disable the second list if the other one is chosen already. We cannot have 2 entries on the same row.
Sep 10 2023 08:29 AM
SolutionIn Excel 365, you can use data validation and a bit of VBA (Visual Basic for Applications) code to create a dynamic dropdown list in Column B that depends on the selection in Column A and disable it when a selection is made in Column B. Here is how you can achieve this:
Step 1: Set Up Data Validation
Step 2: Create a Dynamic Dropdown List
=IF(A2<>"", B2:B10, "")
This formula will display the options in B2:B10 only if a selection is made in the corresponding cell in Column A.
Step 3: Disable the Dropdown List
To disable the dropdown list in Column B when a selection is made in Column A, you can use VBA. Here is an example of VBA code that disables the dropdown list in Column B when a selection is made in Column A:
vba code:
Private Sub Worksheet_Change(ByVal Target As Range)
If Target.Column = 1 Then ' Check if the change occurred in Column A
If Target.Value <> "" Then
' Disable the dropdown list in Column B
Me.Range("B2:B" & Me.Cells(Me.Rows.Count, "B").End(xlUp).Row).Validation.Delete
End If
End If
End Sub
To use this code:
Now, when a selection is made in Column A, the dropdown list in Column B will be disabled, and the user will not be able to make another selection in the same row. The text was created with the help of AI.
My answers are voluntary and without guarantee!
Hope this will help you.
Was the answer useful? Mark them as helpful and like it!
This will help all forum participants.
Sep 23 2023 06:43 AM
Good morning, I want to thank you for the information. It did work and I was finally able to accomplish my task for work. Many thanks sir
Ben Charles