Use selected items from a ListBox - Mistmatch error

Dalua

New Member
Joined
Aug 9, 2016
Messages
5
I am trying to use specific values from a listbox. I have managed to move this into a different one. But Iam not able to use this values so I am trying to put all the values in a collection to later use them. But i keep having a Mistmatch error

In the ListBox i have the name of different files, and in the collection I suppose to have the full address and the extension of the files for later use.

Private Sub cmdAdd_Click()
Dim intListX As Long, FileName As String, Title As String

For intListX = UserForm1.LstSelected.ListCount - 1 To 0 Step -1

If UserForm1.LstAvail.Selected(intListX) Then
UserForm1.LstSelected.AddItem LstAvail.List(intListX)
FileName = SavePath & UserForm1.LstAvail.List(intListX) & ".txt"
colSelFilesSeq.Add FileName

UserForm1.LstAvail.RemoveItem intListX

End If
Next
' For Each sFile In colSelFileSeq
' MsgBox sFile
' Next sFile

End Sub
 

Excel Facts

Which Excel functions can ignore hidden rows?
The SUBTOTAL and AGGREGATE functions ignore hidden rows. AGGREGATE can also exclude error cells and more.
Where do you get the error?
 
Upvote 0
At the end of the code there are three lines that are as commentaries but these are the ones that I am using in another Sub and here is where I am getting the error.
 
Upvote 0

Forum statistics

Threads
1,214,957
Messages
6,122,472
Members
449,087
Latest member
RExcelSearch

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top