Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
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
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3,986
Default 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
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
Narrow Range based on Selection in Another Range David Excel Discussion (Misc queries) 3 July 1st 07 05:12 PM
Identifying a selection of a selection of a range swimfast Excel Worksheet Functions 1 March 1st 07 02:51 AM
Urgent, help needed on range selection! aiyer[_32_] Excel Programming 1 August 6th 04 10:58 PM
Excel VBA - Range(Selection, Selection.End(xlDown)).Name issue. jonH Excel Programming 3 June 7th 04 09:13 PM
SELECTION INFORMATION NEEDED PLEASE HELP Kaan Demirtas Excel Programming 2 September 17th 03 05:38 PM


All times are GMT +1. The time now is 03:01 AM.

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

About Us

"It's about Microsoft Excel"