• Hi All

    Please note that at the Chandoo.org Forums there is Zero Tolerance to Spam

    Post Spam and you Will Be Deleted as a User

    Hui...

  • When starting a new post, to receive a quicker and more targeted answer, Please include a sample file in the initial post.

Multi-select ListBox issue - Code not working

cacos

Member
Hi!


I'm having a hard time with a multi-select listbox I'm using on a particular file.


Here's the link: https://docs.google.com/file/d/0B9nov_b3A5SvcDAxTWhaaUlRb2s/edit?usp=sharing


The listbox is in the sheet "C2".


The code on the multi-select works OK everywhere except on this file. It's a file that Narayank helped me set up and has Workbook_Open code that I think might be creating the conflict.


Thanks a lot!
 
Hi ,


I am not sure that the code would work everywhere except this one file. Anyway , replace your existing Update_Click procedure with this :

[pre]
Code:
Private Sub Update_Click()
Dim lItem As Integer, j As Integer
Dim selected_items() As String

With Sheets("C2").ListBox1
ReDim selected_items(.ListCount - 1)
For lItem = 0 To .ListCount - 1
If .Selected(lItem) Then
selected_items(j) = .List(lItem)
j = j + 1
End If
Next
End With

Worksheets("CRaw").Range("A1:A100").ClearContents

For lItem = LBound(selected_items) To UBound(selected_items)
If selected_items(lItem) <> "" Then
Sheet10.Range("A100").End(xlUp)(2, 1).Value = selected_items(lItem)
End If
Next
End Sub
[/pre]
Narayan
 
It's perfect Narayan, thanks (yet again). Yes it worked fine in other workbooks, I don't understand why. I'll look into your code it's probably smarter.


Thanks a lot.
 
Back
Top