comman button on form to transfer items in listbox to a sheet
Can the Add item be a range? In one list box I have 1200 employees that can
be possibly selected.
"Dave Peterson" wrote:
Maybe you could use something like:
Option Explicit
Private Sub CommandButton1_Click()
Dim DestCell As Range
Dim iCtr As Long
With Worksheets("sheet1")
Set DestCell = .Range("A1")
End With
With Me.ListBox1
DestCell.Resize(.ListCount, 1).ClearContents
For iCtr = 0 To .ListCount - 1
If .Selected(iCtr) Then
DestCell.Value = .List(iCtr)
Set DestCell = DestCell.Offset(1, 0)
End If
Next iCtr
End With
End Sub
Private Sub UserForm_Initialize()
With Me.ListBox1
.MultiSelect = fmMultiSelectMulti
.AddItem "a"
.AddItem "b"
.AddItem "c"
.AddItem "d"
.AddItem "e"
End With
End Sub
gbpg wrote:
I have form that has a number of list boxes that use command buttons to
transfer items from one list box to another, I want to save the items to a
sheet with a command button. Can do this with a text box but not with a list
box. Can some one give an example?
--
Dave Peterson
|