Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
Cannot dropitem from multiselect listbox
I'm transferring data from one listbox to another based on a users
selection. Once the selection is transferred to the second listbox, I would like to drop the items that are selected in listbox one. I'd greatly appreciate suggestions. thx. Edward |
#2
Posted to microsoft.public.excel.programming
|
|||
|
|||
Cannot dropitem from multiselect listbox
Maybe this will help:
http://groups.google.com/groups?thre...1043%40msn.com ej_user wrote: I'm transferring data from one listbox to another based on a users selection. Once the selection is transferred to the second listbox, I would like to drop the items that are selected in listbox one. I'd greatly appreciate suggestions. thx. Edward -- Dave Peterson |
#3
Posted to microsoft.public.excel.programming
|
|||
|
|||
Cannot dropitem from multiselect listbox
Thx. Dan for your direction to a previous post. It does address my difficulties; however, I'm still running into a run-time error with the removeitem and clear listbox methods. *** Sent via Developersdex http://www.developersdex.com *** Don't just participate in USENET...get rewarded for it! |
#4
Posted to microsoft.public.excel.programming
|
|||
|
|||
Cannot dropitem from multiselect listbox
You may want to post the portion of code that's causing the trouble.
And a few more details--is this on a userform or is this on a worksheet? And if it's on a worksheet, did you use the controls from the control toolbox toolbar or from the Forms toolbar? Edward Glover wrote: Thx. Dan for your direction to a previous post. It does address my difficulties; however, I'm still running into a run-time error with the removeitem and clear listbox methods. *** Sent via Developersdex http://www.developersdex.com *** Don't just participate in USENET...get rewarded for it! -- Dave Peterson |
#5
Posted to microsoft.public.excel.programming
|
|||
|
|||
Cannot dropitem from multiselect listbox
The listboxes and cmd button objects are on a user form. I'm getting run-time errors on the lines that contain clear and removeitem methods. The msgbox error is Run-time error '-2147467259 (80004005)': Unspecified error. For iCtr = Me.ListBox2.ListCount - 1 To 0 Step -1 If Me.ListBox2.Selected(iCtr) = True Then Me.ListBox2.RemoveItem iCtr End If Next iCtr and Me.ListBox1.Clear thx. for your time. Edward *** Sent via Developersdex http://www.developersdex.com *** Don't just participate in USENET...get rewarded for it! |
#6
Posted to microsoft.public.excel.programming
|
|||
|
|||
Cannot dropitem from multiselect listbox
How did you populate those listboxes?
If you used the .rowsource, try looping through the range and populating one at a time or plop the values in the range into listbox: Private Sub UserForm_Initialize() Dim iCtr As Long With Me.ListBox1 .ListFillRange = Worksheets("sheet1") _ .Range("a1:a10").Address(external:=True) End With With Me.ListBox2 .ListFillRange = Worksheets("sheet1") _ .Range("b1:b10").Address(external:=True) End With Me.ListBox1.MultiSelect = fmMultiSelectMulti Me.ListBox2.MultiSelect = fmMultiSelectMulti End Sub Edward Glover wrote: The listboxes and cmd button objects are on a user form. I'm getting run-time errors on the lines that contain clear and removeitem methods. The msgbox error is Run-time error '-2147467259 (80004005)': Unspecified error. For iCtr = Me.ListBox2.ListCount - 1 To 0 Step -1 If Me.ListBox2.Selected(iCtr) = True Then Me.ListBox2.RemoveItem iCtr End If Next iCtr and Me.ListBox1.Clear thx. for your time. Edward *** Sent via Developersdex http://www.developersdex.com *** Don't just participate in USENET...get rewarded for it! -- Dave Peterson |
#7
Posted to microsoft.public.excel.programming
|
|||
|
|||
Cannot dropitem from multiselect listbox
You've solved my problem. I had the range set in the listbox rowsource properties window (Sheet1! A3:A25), however your last response led me to populating the listbox through the userfrm_initialize procedure. This resulted in the code executing the removeitem and clear listbox methods. I wasn't able to take advantage of the sample code you provided because the listfillrange listbox method was not recognized. Instead I used the following: Private Sub UserForm_Initialize() Dim cell As Range Dim Rng As Range With ThisWorkbook.Sheets("Sheet1") Set Rng = .Range("a3", "a25") End With For Each cell In Rng.Cells Me.ListBox1.AddItem cell.Value Next cell Me.ListBox1.MultiSelect = fmMultiSelectMulti Me.ListBox2.MultiSelect = fmMultiSelectMulti End Sub thx. for all your responses. I really appreciate your assistance. Edward *** Sent via Developersdex http://www.developersdex.com *** Don't just participate in USENET...get rewarded for it! |
#8
Posted to microsoft.public.excel.programming
|
|||
|
|||
Cannot dropitem from multiselect listbox
I pasted the wrong code (sigh).
I meant this: Private Sub UserForm_Initialize() Dim iCtr As Long With Me.ListBox1 .List = Worksheets("sheet1").Range("a1:a10").Value End With With Me.ListBox2 .List = Worksheets("sheet1").Range("b1:b10").Value End With Me.ListBox1.MultiSelect = fmMultiSelectMulti Me.ListBox2.MultiSelect = fmMultiSelectMulti End Sub You don't need to go cell by cell. (sorry.) I think I had the worksheet version in another module and screwed up by copying from there. Edward Glover wrote: You've solved my problem. I had the range set in the listbox rowsource properties window (Sheet1! A3:A25), however your last response led me to populating the listbox through the userfrm_initialize procedure. This resulted in the code executing the removeitem and clear listbox methods. I wasn't able to take advantage of the sample code you provided because the listfillrange listbox method was not recognized. Instead I used the following: Private Sub UserForm_Initialize() Dim cell As Range Dim Rng As Range With ThisWorkbook.Sheets("Sheet1") Set Rng = .Range("a3", "a25") End With For Each cell In Rng.Cells Me.ListBox1.AddItem cell.Value Next cell Me.ListBox1.MultiSelect = fmMultiSelectMulti Me.ListBox2.MultiSelect = fmMultiSelectMulti End Sub thx. for all your responses. I really appreciate your assistance. Edward *** Sent via Developersdex http://www.developersdex.com *** Don't just participate in USENET...get rewarded for it! -- Dave Peterson |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Multiselect Listbox use | Excel Discussion (Misc queries) | |||
multiselect on a listbox from Control toolbox | Excel Programming | |||
MultiSelect ListBox in Excel | Excel Programming | |||
Excel VBA-Looping though MultiSelect on ListBox | Excel Programming | |||
multiselect listbox | Excel Programming |