Seeking help with list box crash

AlexanderBB

Well-known Member
Joined
Jul 1, 2009
Messages
1,953
Office Version
  1. 2019
  2. 2016
Platform
  1. Windows
I started this thread but it's kind of dried up and I'm still struggling with a list box problem.

http://www.mrexcel.com/forum/excel-questions/910357-list-box-woes-2.html#post4379907

There's 3 boxes involved. If I click - then shift click the same item in, say List 1 , then click in another listbox instead of deselecting everything in List 1 as intended, it selects each previous item and moves back with every click until it reaches the top. Then reports "Could not set the Selected property. Unspecified error." on the line with command .Selected(i) = False where i is 0.

I'm hoping it's something in my code but think it's a bug in Excel. I say that because it sometimes works, but always fails the first time.
Are any guru's around who can prove that? Plus how's best to demonstrate this? I can't paste in a piece of code as the Form & Controls are needed.

Any help appreciated. Been 3 days trying to figure this out !
 

Excel Facts

Can a formula spear through sheets?
Use =SUM(January:December!E7) to sum E7 on all of the sheets from January through December
Plus how's best to demonstrate this?
and from the other thread
Or can I post a dropbox link ?

Yes to the 2nd quote which answers the first

I can't paste in a piece of code as the Form & Controls are needed

of course you still can and let the people reading the thread decide if they can do anything with it (in fact despite my answer to the first 2 quotes above I still would as some won't/can't download files).

Hopefully then you might get a bit more success :)
 
Upvote 0
To figure anything out you'd probably, need to observe it all. The dropbox link is

https://dl.dropboxusercontent.com/u/49222457/ListError.zip

If you click 1952 then shift-click 1952 then click another list box
the 1952 selection moves back on each click until the error.

All that last click should do is deselect everything in Listbox 1.
Nothing is telling it to move back by one.
 
Upvote 0
Fixed! And in case it helps anyone else

Code:
Sub clearbox2(cListbox As MSForms.ListBox) Dim i As Integer
If Not cListbox Is Nothing Then
    With cListbox
'          For i = 0 To .ListCount - 1
'              .Selected(i) = False
'            Next
            .MultiSelect = fmMultiSelectSingle
            .MultiSelect = fmMultiSelectExtended
    End With
End If
End Sub

The 2 additional .MultiSelect = lines are what fixed it all.
 
Upvote 0

Forum statistics

Threads
1,221,545
Messages
6,160,446
Members
451,646
Latest member
mmix803

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