Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
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 |
#2
Posted to microsoft.public.excel.programming
|
|||
|
|||
range selection help needed
The multiselect property is set by opening the VBE, selecting the userform
your listbox is on and then selecting the listbox. The properties window should appear on the lower left where you can then set your multiselect to true. "trward79" wrote: 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 |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Narrow Range based on Selection in Another Range | Excel Discussion (Misc queries) | |||
Identifying a selection of a selection of a range | Excel Worksheet Functions | |||
Urgent, help needed on range selection! | Excel Programming | |||
Excel VBA - Range(Selection, Selection.End(xlDown)).Name issue. | Excel Programming | |||
SELECTION INFORMATION NEEDED PLEASE HELP | Excel Programming |