Listbox errors when empty

ernief

New Member
Joined
Dec 9, 2017
Messages
8
Hi guys
I am having a couple of problems with a listbox when there are no rows in it.
I have an original sheet "OpenIssues" containing all of the data. There are then three optional comboboxes which filter the original data down dynamically to a sheet "FilteredIssues". The dynamic ranges work fine when there are rows to show in the listbox, but when there are no rows to show I get either a 1004 error or a 380 error in a couple of places in the code

Error 380 occurs in the following code snippet

If CurrentRecordID > 1 Then
ReportListBox.ListIndex = CurrentRecordID - 2
Else
ReportListBox.ListIndex = 1
End If

CurrentRecordID = 1 biut the error occurs at ReportListBox.ListIndex = 1

Error 1004 occurs in the following code snippet

Private Sub FillListBox()


Call SelectFirstBlankCell

Dim r As Integer
r = ReportListBox.ListIndex ' + 1
If r < 0 Then r = 1


Range("FilterOpenIssues").Select

....more code
EndSub


Is there a way to trap the listbox when there are no rows to be displayed
Thanks
Ernie
 

Excel Facts

What did Pito Salas invent?
Pito Salas, working for Lotus, popularized what would become to be pivot tables. It was released as Lotus Improv in 1989.

Forum statistics

Threads
1,224,830
Messages
6,181,227
Members
453,025
Latest member
Hannah_Pham93

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