Multi select dropdown inside of a table

Not_Again

New Member
Joined
Feb 4, 2025
Messages
3
Office Version
  1. 365
Platform
  1. Windows
Hello. I am trying to make a dropdown in which you can select more than one choice per cell. It is working well, UNTIL I try to create the data validation in a cell that is within a table. (See picture)
If I use the code and data validation in a cell NOT in a table, it works great. How can I get a multichoice dropdown in a cell that is in a table?

This is the code I am using:
VBA Code:
Private Sub Worksheet_Change(ByVal Target As Range)
Dim Oldvalue As String
Dim Newvalue As String
Application.EnableEvents = True
On Error GoTo Exitsub
    Const rngA = "K2:K1639"
    If Not Intersect(Target, Target.Parent.Range(rngA)) Is Nothing 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
If InStr(1, Oldvalue, Newvalue) = 0 Then
Target.Value = Oldvalue & ", " & Newvalue
Else:
Target.Value = Oldvalue
End If
End If
End If
End If
Application.EnableEvents = True
Exitsub:
Application.EnableEvents = True
End Sub


Thank you for helping!!
 

Attachments

  • Screenshot 2025-02-04 140902.png
    Screenshot 2025-02-04 140902.png
    6.2 KB · Views: 6
Last edited by a moderator:

Excel Facts

Can a formula spear through sheets?
Use =SUM(January:December!E7) to sum E7 on all of the sheets from January through December
Welcome to the MrExcel board!

When posting vba code in the forum, please use the available code tags. It makes your code much easier to read/debug & copy. My signature block at the bottom of this post has more details. I have added the tags for you this time. (It would also be better if the code was indented better) 😊

I tested the code with column K as part of a table and it worked fine as far as I can tell.
What, exactly, goes wrong for you when the target range is in a table?
 
Last edited:
Upvote 0
Thanks Peter,
The dropdown works as intended, with multiple options to populate, however when I am done it shows an error (see picture) and it states, "Restriction: Value must match one of the listed items."
 

Attachments

  • Screenshot 2025-02-05 080426.png
    Screenshot 2025-02-05 080426.png
    10.2 KB · Views: 3
Upvote 0
Try this. Go to
File -> Options -> Formulas -> Error checking rules -> Clear the checkbox below -> OK

1738804627627.png
 
Upvote 0
Solution

Forum statistics

Threads
1,226,453
Messages
6,191,135
Members
453,642
Latest member
jefals

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