Add a Range to a VBA - Multi-Choice Drop Down

Geordiegirl83

New Member
Joined
May 13, 2016
Messages
29
Hi All,

I'm sure this is a simple fix but I cant get it to work at all. I have the below code which allows multi choice to all of my drop downs on a form i have created, but I only want the drop downs in Col. E & H to be multi-choice and I would like all other drop downs in the sheet to be single choice options.

At the moment I can only get them to ALL be multi choice or ALL be single choice ... HELP!

CODE:

Private Sub Worksheet_Change(ByVal Target As Range)

Dim xRng As Range
Dim xValue1 As String
Dim xValue2 As String

If Target.Count > 1 Then Exit Sub
On Error Resume Next
Set xRng = Cells.SpecialCells(xlCellTypeAllValidation)
If xRng Is Nothing Then Exit Sub
Application.EnableEvents = False

If Not Application.Intersect(Target, xRng) Is Nothing Then
xValue2 = Target.Value
Application.Undo
xValue1 = Target.Value
Target.Value = xValue2
If xValue1 <> "" Then
If xValue2 <> "" Then
If xValue1 = xValue2 Or _
InStr(1, xValue1, ", " & xValue2) Or _
InStr(1, xValue1, xValue2 & ",") Then
Target.Value = xValue1
Else
Target.Value = xValue1 & ", " & xValue2
End If
End If
End If
End If
Application.EnableEvents = True
End Sub
 

Excel Facts

Difference between two dates
Secret function! Use =DATEDIF(A2,B2,"Y")&" years"&=DATEDIF(A2,B2,"YM")&" months"&=DATEDIF(A2,B2,"MD")&" days"
Hi @Geordiegirl83
Thanks for posting on the forum.

After this line:
VBA Code:
If Target.Count > 1 Then Exit Sub

Add this line:
VBA Code:
If Intersect(Target, Range("E:H")) Is Nothing Then Exit Sub

--------------
Let me know the result and I'll get back to you as soon as I can.
Cordially
Dante Amor
--------------​
 
Upvote 0
Hi @Geordiegirl83
Thanks for posting on the forum.

After this line:
VBA Code:
If Target.Count > 1 Then Exit Sub

Add this line:
VBA Code:
If Intersect(Target, Range("E:H")) Is Nothing Then Exit Sub

--------------
Let me know the result and I'll get back to you as soon as I can.
Cordially
Dante Amor
--------------​
Hi & Thanks for your reply.

This kind of works for most part, but I want only Col E & Col H to be multi-choice - I have a drop down in F also, which i want to be single option only, as its a dependant drop down for another cell.
 
Upvote 0

Forum statistics

Threads
1,224,823
Messages
6,181,181
Members
453,022
Latest member
Mohamed Magdi Tawfiq Emam

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