Choosing Multiple items from Data Validation Lists

A

Alex

I have the following code that allows users to pick multiple choices from a
data validation list. The problem with the code is that users can pick
multiple choices from all the lists in the worksheet and not just F, J, V, O.
How can I change this to only allow users to choose multiple items in those
columns? Thanks.

If Application.Intersect(Target, Range("F2:F25,U2:U25,V2:V25,02:025")) Is
Nothing Then Exit Sub

For Each cell In Target
Application.EnableEvents = False
On Error GoTo exitHandler
newVal = cell.Value
Application.Undo
oldVal = cell.Value
cell.Value = newVal

If oldVal = "" Then
'do nothing
Else
If newVal = "" Then
'do nothing
Else
cell.Value = oldVal _
& ";# " & newVal
End If
End If



Next cell

exitHandler:
Application.EnableEvents = True
 
M

Melanie Breden

Hi Alex,

Alex" said:
I have the following code that allows users to pick multiple choices from a
data validation list. The problem with the code is that users can pick
multiple choices from all the lists in the worksheet and not just F, J, V, O.
How can I change this to only allow users to choose multiple items in those
columns? Thanks.

If Application.Intersect(Target, Range("F2:F25,U2:U25,V2:V25,02:025")) Is
Nothing Then Exit Sub

in the Range 02:025 you use the number 0 instead of the letter O.
This should work for you:

If Application.Intersect(Target, Range("F2:F25,U2:U25,V2:V25,O2:O25")) _
Is Nothing Then Exit Sub


Mit freundlichen Grüssen
Melanie Breden

- Microsoft MVP für Excel -
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top