Select Multiple Items From Drop Down (Data Validation) List
Select Multiple Items From Drop Down (Data Validation) List
Select Multiple Items From Drop Down (Data Validation) List
Validation) List
APRIL 20, 2020 BY PHILIP TREACY 51 COMMENTS
multi-dv.mp4
Data validation lists will only let you choose one item from the list. But what if we have a
situation where we want to choose more than one item?
Select Multiple
Watch the Video Items DropDown.mp4
When a selection is made from the DV list, we can intercept the change using
a Worksheet_Change event.
Worksheet_Change is triggered by a change to any cell on the sheet, so the code needs
to check if the changed cell is using our data validation list.
As usual the changed range is passed into the event with a variable called Target, and I've
created a named range, DV_Range, that refers to C1:C4 where I'm using the data
validation.
If Target and DV_Range Intersect then the data validation lists are being used. If they
don't intersect then the code doesn't need to do anything.
Here's the trick. Store the newly selected choice from the DV list. At this point the cell has
been changed and shows only the new selection from the DV list.
Undo the change
The cell now contains the value before a new DV selection was made, store this value.
If the old value was nothing, the cell should contain the new selection
If the new value is nothing, the cell contents are being deleted
If neither of these things are true, join the old value and the new value (they are
strings), separated by a comma in this case, and put this into the cell.