ListBox.ListIndex giving an error

ernief

New Member
Joined
Dec 9, 2017
Messages
8
Hi
I have a listbox "ReportListBox" and the ReportListBox.ListIndex is tyoe Variant/Long
I have set up a variable rng with dim as Variant and also have tried Long.
I then use rng = Range("filteropenissues").Rows.Count.
When I try to process the code line ReportListBox.ListIndex = rng I get a 380 Error "Could Not set the listindex property."
The value of ReportListBox.ListIndex at this point is 1 and rng is 59 (either in Variant or Long)
If I replace rng with CurrentRecordID (Long) with a value of 2 I don't get an error.
Can anyone explain why this is happening
Thanks
Ernie
 
Last edited:

Excel Facts

Wildcard in VLOOKUP
Use =VLOOKUP("Apple*" to find apple, Apple, or applesauce
Hi,
The ListIndex is zero based (0 is for the 1st item), therefore use ReportListBox.ListIndex = rng - 1
Regards
 
Upvote 0

Forum statistics

Threads
1,224,823
Messages
6,181,184
Members
453,020
Latest member
Mohamed Magdi Tawfiq Emam

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