List Box RowSource VBA Array Restrict # Rows

michaeldh

Board Regular
Joined
Jun 11, 2002
Messages
201
Hi,

I have a mutlidimensional array that fills a listbox. It is an array as follows:

vArray(1 to 65536)

The list box basically has thousands of rows of blank data in it as a result of:

Listbox1.list = vArray

Is there a way to make the listbox not show all the blank data and to only show the rows that contain a value.

Thanks.

Michael.
 

Excel Facts

When did Power Query debut in Excel?
Although it was an add-in in Excel 2010 & Excel 2013, Power Query became a part of Excel in 2016, in Data, Get & Transform Data.
Code:
Dim oneElement as Variant

With ListBox1
    For each oneElement in vArray
        If oneElement <> vbNullString then ListBox1.AddItem oneElement
    Next oneElement
End With

I'm tempted to ask, why such a huge range with so little data scattered about that empty space.

How many non-blank elements are in your list box?
Too many and it becomes a bother for the user, design time spent alphabetizing and showing only a portions of the alphabet at a time might make the users life a lot easier.
 
Last edited:
Upvote 0

Forum statistics

Threads
1,224,550
Messages
6,179,459
Members
452,915
Latest member
hannnahheileen

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