Dropdown list activated if condition met

emutuc

New Member
Joined
Dec 19, 2022
Messages
13
Office Version
  1. 365
Platform
  1. Windows
Greetings MrExcel.com friends!

I am kindly seeking your suggestions for a conditional drop downlist if a condition met.
For example, if the condition, "Single" is met, then I would like a drop down list with the options of "1" or "2" or "3". If the "Single" condition is not met, I would like the cell to be blank.

Many many thanks again for your help

Eric
 

Excel Facts

Copy formula down without changing references
If you have =SUM(F2:F49) in F50; type Alt+' in F51 to copy =SUM(F2:F49) to F51, leaving the formula in edit mode. Change SUM to COUNT.
Try adding this to the Sheet code. Without knowing your sell specific the below will have Cell A2 as Validation dropdown If cell "A1" is "Single"

VBA Code:
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
    If Range("A1") = "Single" Then
        Range("A2").Validation.Add Type:=xlValidateList, AlertStyle:=xlValidAlertStop, _
        Formula1:="1,2,3"
    ElseIf Range("A1") <> "Single" Then
        Range("A2").Validation.Delete
        Range("A2").ClearContents
    End If
End Sub
 
Last edited:
Upvote 0
This might be better as the one above can result in a debug Error when delete the values in other cells
VBA Code:
Private Sub Worksheet_Change(ByVal Target As Range)
    If Not Intersect(Target, Range("A1")) Is Nothing Then
        If Target = "Single" Then
            Range("A2").Validation.Add Type:=xlValidateList, AlertStyle:=xlValidAlertStop, _
            Formula1:="1,2,3"
        Else
            Application.EnableEvents = False
            Range("A2").Validation.Delete
            Range("A2").ClearContents
            Application.EnableEvents = True
        End If
    End If
End Sub
 
Upvote 0
Many thanks hajiali. I tried to interpret this, but I'm having trouble. Can you please translate in xls?
 
Upvote 0
Many thanks hajiali. I tried to interpret this, but I'm having trouble. Can you please translate in xls?
So the above code is a Sheet code. you will need to right-click on the Sheet name at the bottom of Excel and Click the View Code Option. Copy the code and close.
When saving the workbook you will need to save it as XLSM instead of XLS.
 
Upvote 0

Forum statistics

Threads
1,214,929
Messages
6,122,317
Members
449,081
Latest member
tanurai

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