View Single Post
  #1   Report Post  
Posted to microsoft.public.excel.programming
trward79 trward79 is offline
external usenet poster
 
Posts: 20
Default range selection help needed

I have a form that I use to select data from a range on the page which works
fine, and if it is selected from the list, it moves to a second box, and then
when Run is clicked, it processes the data from ListBox2 to the range of A2.
This is where I have the issue of selecting all the values of the list Box
and copying them to the sheet. I also have a problem making them
multi-select. I am including my code here to see if anyone can help.

Private Sub CommandButton2_Click()
Worksheets("Auto_Working").Select
Range("A2:A1502").ClearContents
' This is where it only moves the value if it is selected in the ListBox2,
and not all
' values like I need it to. Also ListBox2 is not Multi-Select
WorkSheets("AutoWorking").Range("A2").Value = ListBox2.Value
Moudule1.Added_Employee
End Sub

'This retrieves values from worksheet to listbox1
Private Sub UserForm_Initialize()
Dim myCell As Range
Dim myRng As Range
Dim myWord As String

myWord= "Employee"
With Worksheets("Auto_Working")
Set myRng = .Range("A1", .Cells(.Rows.Count, "A").End(xlUp))
End With
For Each myCell In myRng.Cells
If LCase(Left(myCell.Value, Len(myWord))) < LCase(myWord) Then
Me.ListBox1.AddItem myCell.Value
End If
Next myCell
End Sub

'This copies values selected from listbox1 to listbox2
Private Sub CommandButton1_Click()
If Me.ListBox1.Value < "" Then
Me.ListBox2.AddItem Me.ListBox1.Value
TextBox1.Value = Me.ListBox1.Value
End If
End Sub