Home |
Search |
Today's Posts |
|
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Probably this is a stupid question, but the closest answer I can find
anywhere is Debra Dagleish's code that allows for consecutive selections from a data-validation dropdown to be entered in a cell, separated by commas. For a few reasons I'd rather do something with a ListBox in a UserForm. On the UserForm is a ListBox (called ListBox2) which can contain any number of items. When a user clicks a button on the UserForm, is it possible to have those items, separated by commas, deposited into the Active Cell on the current worksheet? If anyone could help, I'd really appreciate it. I keep finding close alternatives to what I need, but nothing that quite hits it, and I'm clearly I'm just not smart enough to do this. |
#2
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Try
Private Sub CommandButton2_Click() Dim N As Long Dim S As String With Me.ListBox1 If .ListCount = 0 Then Exit Sub End If For N = 0 To .ListCount - 1 S = S & .List(N) & "," Next N End With S = Mid(S, 1, Len(S) - 1) ActiveCell.Value = S End Sub Cordially, Chip Pearson Microsoft Most Valuable Professional Excel Product Group, 1998 - 2009 Pearson Software Consulting, LLC www.cpearson.com (email on web site) On Fri, 20 Feb 2009 12:26:01 -0800, Daystrom wrote: Probably this is a stupid question, but the closest answer I can find anywhere is Debra Dagleish's code that allows for consecutive selections from a data-validation dropdown to be entered in a cell, separated by commas. For a few reasons I'd rather do something with a ListBox in a UserForm. On the UserForm is a ListBox (called ListBox2) which can contain any number of items. When a user clicks a button on the UserForm, is it possible to have those items, separated by commas, deposited into the Active Cell on the current worksheet? If anyone could help, I'd really appreciate it. I keep finding close alternatives to what I need, but nothing that quite hits it, and I'm clearly I'm just not smart enough to do this. |
#3
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
You're a god, Chip! It works perfectly--thank you so much! Sorry about the
slow replay, but I had to leave work early yesterday to visit (horribly) with my parents in law, so I just saw this. You've made this whole weekend much better. Again, thank you! "Chip Pearson" wrote: Try Private Sub CommandButton2_Click() Dim N As Long Dim S As String With Me.ListBox1 If .ListCount = 0 Then Exit Sub End If For N = 0 To .ListCount - 1 S = S & .List(N) & "," Next N End With S = Mid(S, 1, Len(S) - 1) ActiveCell.Value = S End Sub Cordially, Chip Pearson Microsoft Most Valuable Professional Excel Product Group, 1998 - 2009 Pearson Software Consulting, LLC www.cpearson.com (email on web site) On Fri, 20 Feb 2009 12:26:01 -0800, Daystrom wrote: Probably this is a stupid question, but the closest answer I can find anywhere is Debra Dagleish's code that allows for consecutive selections from a data-validation dropdown to be entered in a cell, separated by commas. For a few reasons I'd rather do something with a ListBox in a UserForm. On the UserForm is a ListBox (called ListBox2) which can contain any number of items. When a user clicks a button on the UserForm, is it possible to have those items, separated by commas, deposited into the Active Cell on the current worksheet? If anyone could help, I'd really appreciate it. I keep finding close alternatives to what I need, but nothing that quite hits it, and I'm clearly I'm just not smart enough to do this. |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
bind data to active x listbox without macro | Excel Discussion (Misc queries) | |||
All selected listbox values to a cell? | Excel Programming | |||
Userform Listbox using an active sheet | Excel Discussion (Misc queries) | |||
Multiselect ListBox - Active/Inactive Items | Excel Programming | |||
Moving cell values from sheet2 to sheet1 using UserForms and ListBox | Excel Programming |