data validation - select multiple options?

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

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).
 
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
 
Not exactly what you asked, but see if this might be able to help you.

As you pick from the list, the choices are eliminated from the display,
preventing duplicate selections.

http://www.contextures.com/xlDataVal03.html

--

HTH,

RD
=====================================================
Please keep all correspondence within the Group, so all may benefit!
=====================================================

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).
 

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

Back
Top