View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.misc
Dave Peterson
 
Posts: n/a
Default data validation - select multiple options?

Not really.

Maybe you could use a listbox.

I added a listbox from the Forms toolbar to a worksheet.
I called it "List Box 1".

I rightclicked on that listbox and chose Format Control. On the Control tab, I
chose Selection Type of Multi. I also pointed at the range that held the values
that go in that listbox.

Then I added a button from the Forms toolbar (I click the button when I'm done
with my selections).

Then I assigned this code to the button:

Option Explicit
Sub testme()

Dim myLB As ListBox
Dim iCtr As Long
Dim myCell As Range

Dim myRng As Range

With ActiveSheet
Set myLB = .ListBoxes("list box 1")
Set myCell = .Range("B1")
End With

With myLB
ActiveSheet.Range("B1").Resize(.ListCount, 1).ClearContents

For iCtr = 1 To .ListCount
If .Selected(iCtr) Then
myCell.Value = .List(iCtr)
Set myCell = myCell.Offset(1, 0)
'.Selected(iCtr) = False
End If
Next iCtr
End With
End Sub

I commented the ".Selected(ictr) = false". Uncomment that line if you want the
selections cleared after the range is updated.

And I put the selected items in B1:B???

If you're new to macros, you may want to read David McRitchie's intro at:
http://www.mvps.org/dmcritchie/excel/getstarted.htm

A. wrote:

Is it possible to create a similar function like data validation, from which
I can select multiple options?

(Background: I need a list of many names, from which I case by case can
select).


--

Dave Peterson