Multiple Select Drop in a Single Cell

scoobydoo

New Member
Joined
Jan 6, 2010
Messages
32
Office Version
  1. 365
Platform
  1. Windows
Hello! I'm attempting to use a drop down list for requests to update a row of data. The drop down list options are in Column A2:A8 in my sample data. I would like to make the multiple select drop down in Column C. There may be more rows of data at any given time. I'm trying to select all types of updates that are needed for each row. I only entered $C$2 in the VBA Code. However, I need it to include Column C. I used VBA Code below but nothing happens when I test it. I would appreciate help to correct this code that I found in a tutorial.

Private Sub Worksheet_Change(ByVal Target As Range)

' Initializing variables
Dim oldVal As String
Dim newVal As String
' Checking for changes in the drop down lists

Application.EnableEvents = True

If Target.Address = "$C$2" Then

If Target.SpecialCells(xlCellTypeAllValidation) Is Nothing Then
Exit Sub
' Adding the multiple selected items to the list
Else
If Target.Value = "" Then
Exit Sub

Else
Application.EnableEvents = False
newVal = Target.Value
Application.Undo
oldVal = Target.Value
If oldVal = "" Then
Target.Value = newVal
Else
If InStr(oldVal, newVal) = 0 Then
Target.Value = oldVal & ", " & newVal '& vbNewLine &
Else
Target.Value = oldVal
End If
End If
End If
End If
End If

Application.EnableEvents = True

End Sub
 
I was able to revise the code you sent initially, adding the Target.Row > 3 to make it work. I really appreciate all of your help!
I failed to mention that the file format changed. The multiple selection data field moved to Cell D4 (Column Heading in D3). Please see image below. Please see the final code used below.

1737146730841.png


Private Sub Worksheet_Change(ByVal Target As Range)
Dim Oldvalue As String, Newvalue As String
Application.EnableEvents = False
On Error GoTo Exitsub
' Check if the change is in column C and row > 3

If Target.Column = 4 And Target.Row > 3 Then
If Not Target.SpecialCells(xlCellTypeAllValidation) Is Nothing Then

If Target.Value <> "" Then

Newvalue = Target.Value
Application.Undo
Oldvalue = Target.Value

If Oldvalue = "" Then
Target.Value = Newvalue

Else
If InStr(1, Oldvalue, Newvalue) = 0 Then
Target.Value = Oldvalue & "; " & Newvalue

Else

Target.Value = Oldvalue
End If
End If
End If
End If
End If

Exitsub:
Application.EnableEvents = True
End Sub
Sub Multiple_Drop_Down_Selection()

End Sub
 
Upvote 0

Excel Facts

Square and cube roots
The =SQRT(25) is a square root. For a cube root, use =125^(1/3). For a fourth root, use =625^(1/4).

Forum statistics

Threads
1,225,606
Messages
6,185,956
Members
453,333
Latest member
BioCoder84

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