Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 10
Default How to have multiple values in a single cell?

We have data validation to limit user to select one item from list. Do
we have anything like a dropdown box with checkboxes to each items, so
that we can select multiple items? If yes, how to hanle them from vba?
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35,218
Default How to have multiple values in a single cell?

You could use a listbox from the Control toolbox toolbar and a commandbutton
from that same control toolbox toolbar to extract the selected items.

Put a listbox and a commandbutton from that control toolbox toolbar on a
worksheet.

Put some test data in B1:B10 (item list).

The selected items will go in A1:A10.

Rightclick on the worksheet tab that holds these controls and select view code.

Paste this in:

Option Explicit
Private Sub CommandButton1_Click()

Dim DestCell As Range
Dim iCtr As Long

Set DestCell = Me.Range("a1")

With Me.ListBox1
'remove existing entries
DestCell.Resize(.ListCount, 1).ClearContents
For iCtr = 0 To .ListCount - 1
If .Selected(iCtr) = True Then
DestCell.Value = .List(iCtr)
Set DestCell = DestCell.Offset(1, 0)
End If
Next iCtr
End With
End Sub
Private Sub Worksheet_Activate()
With Me.ListBox1
.List = Me.Range("b1:b10").Value
.ListStyle = fmListStyleOption
.MultiSelect = fmMultiSelectMulti
End With
End Sub


Select a different worksheet and then select this worksheet -- I used
worksheet_activate to populate the listbox. I didn't know how it should be
populated.

Then select a few items and click the button.

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

wrote:

We have data validation to limit user to select one item from list. Do
we have anything like a dropdown box with checkboxes to each items, so
that we can select multiple items? If yes, how to hanle them from vba?


--

Dave Peterson
Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
VLookup multiple values - sum returned values into single cell se7098 Excel Worksheet Functions 12 April 2nd 23 07:32 PM
Multiple returned values into a single cell Jeff Excel Discussion (Misc queries) 12 May 29th 09 11:41 PM
Copy multiple values into a single cell Suzanne Excel Programming 4 September 27th 07 07:11 PM
Indentify value from multiple values in a single cell Dave Excel Worksheet Functions 9 December 13th 05 06:57 AM
Toggle multiple values in single cell Chandni Excel Worksheet Functions 5 February 10th 05 12:48 AM


All times are GMT +1. The time now is 06:40 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"