XL97: How to Fill ListBox Control with Multiple RangesLast reviewed: March 13, 1998Article ID: Q161534 |
The information in this article applies to:
SUMMARYThis article contains an example that fills the list of a ListBox control on a UserForm with data from multiple cell ranges.
MORE INFORMATIONYou cannot use the RowSource property to bind a ListBox control to a worksheet when you want the list to draw from multiple ranges. You must loop through the various ranges with a Visual Basic for Applications procedure and add the items to the list one at a time. The following examples populate a ListBox control as it is loaded by using the Initialize event for the UserForm. Microsoft provides programming examples for illustration only, without warranty either expressed or implied, including, but not limited to, the implied warranties of merchantability and/or fitness for a particular purpose. This article assumes that you are familiar with the programming language being demonstrated and the tools used to create and debug procedures. Microsoft support engineers can help explain the functionality of a particular procedure, but they will not modify these examples to provide added functionality or construct procedures to meet your specific needs. If you have limited programming experience, you may want to contact the Microsoft fee-based consulting line at (800) 936-5200. For more information about the support options available from Microsoft, please see the following page on the World Wide Web:
http://www.microsoft.com/support/supportnet/refguide/default.asp Populating the ListBox Directly from Worksheet CellsTo populate the ListBox, follow these steps:
Using an Array to Populate the ListBoxIt is also possible to assign the contents of a Visual Basic array as the list of a ListBox control. The following example reads the values from the worksheet into an array, and then assigns the array to the ListBox control as the list:
REFERENCESFor additional information about populating list boxes in earlier versions of Microsoft Excel, please see the following article here in the Microsoft Knowledge Base:
ARTICLE-ID: Q153603 TITLE : XL: Macro to Fill a List Box with Multiple RangesFor more information about ListBox Controls, click the Office Assistant, type "listbox", click Search, and then click to view "ListBox control"
|
Additional query words: 97 8.00 XL97
© 1998 Microsoft Corporation. All rights reserved. Terms of Use. |