'Allow Select all that Apply in Excel in Multiple Columns on the same sheet
I am creating an activity tracker in Excel. I'd like to be able to "Select all that apply" from drop down lists in two separate columns on the same sheet.
I am using this VBA code for one column:
Private Sub Worksheet_Change(ByVal Target As Range)
'Code by Sumit Bansal from https://trumpexcel.com
' To make mutliple selections in a Drop Down List in Excel
Dim Oldvalue As String
Dim Newvalue As String
On Error GoTo Exitsub
If Target.Column = 6 Then
If Target.SpecialCells(xlCellTypeAllValidation) Is Nothing Then
GoTo Exitsub
Else: If Target.Value = "" Then GoTo Exitsub Else
Application.EnableEvents = False
Newvalue = Target.Value
Application.Undo
Oldvalue = Target.Value
If Oldvalue = "" Then
Target.Value = Newvalue
Else
Target.Value = Oldvalue & ", " & Newvalue
End If
End If
End If
Application.EnableEvents = True
Exitsub:
Application.EnableEvents = True
End Sub
I found this code online, and altered it to apply to all of Column 6 instead of one cell.
I would like this to work for three columns on the sheet, Columns 1, 6, and 9. I imagine this is achieved by adding an Else statement somewhere below my If Target.Column = 6
statement.
Solution 1:[1]
Trying to answer your question, you may change the folowing If statement:
If Target.Column = 6 Then
into
If Target.Column = 1 Or Target.Column = 6 Or Target.Column = 9 Then
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|---|
Solution 1 | Xavier Junqué |