Article ID: 211899
Article Last Modified on 10/11/2006
APPLIES TO
- Microsoft Excel 2000 Standard Edition
This article was previously published under Q211899
SYMPTOMS
If you set the RowSource property of a ListBox control to a range of cells on a worksheet, the column headings in the list box may not be the values in the first row of your data. For example, the column headings in the ListBox control may be "Column A" and "Column B" (without the quotation marks).
CAUSE
This behavior can occur if all of the following conditions are true:
- The range of cells that you are using has labels in the first row.
- You set the RowSource property of the ListBox control to the entire range of your data, including the row with the labels.
- You set the ColumnHeads property of the ListBox control to True.
RESOLUTION
To have the labels appear as column labels in a ListBox control, set the RowSource property of the ListBox control to the range of cells that is beneath the labels. See the "More Information" section for a sample UserForm that demonstrates this behavior.
STATUS
Microsoft has confirmed that this is a problem in the Microsoft products that are listed at the beginning of this article.
MORE INFORMATION
To set the properties of a ListBox control so that the first row of data is used for the column labels in the list box, follow these steps:
- Close and save any open workbooks, and then open a new workbook.
Type the following data in Sheet1:
A1: Name B1: Amount A2: Bob B2: 1 A3: Sue B3: 2 A4: Tom B4: 3 A5: Pat B5: 4
- Start the Visual Basic Editor (press ALT+F11).
- In the Visual Basic Editor, click UserForm on the Insert menu.
- If the Toolbox is not visible, click Toolbox on the View menu. Click the List Box control in the Toolbox, and then draw a list box on the UserForm.
In the Properties window, set the following properties for the ListBox control:
Property Value -------------------------- ColumnHeads True ColumnCount 2 RowSource Sheet1!A2:B5
- Run the UserForm. To do so, select the UserForm, and then click Run Sub/UserForm on the Run menu.
The labels in A1 and B1 are the column labels in the list box, and the first row of selectable data is from A2 and B2.
NOTE: If you set the RowSource property to "Sheet1!A1:B5" (without the quotation marks), and then run the UserForm, the data in A1 and B1 is a selectable row in the list box, and the column headings are "Column A" and "Column B," respectively.
REFERENCES
For more information about the ListBox control, in the Visual Basic Editor, click Microsoft Visual Basic Help on the Help menu, type things you can do with a multicolumn listbox or combobox in the Office Assistant or the Answer Wizard, and then click Search to view the topic.
Additional query words: list box row source XL2000
Keywords: kbbug kbpending kbprogramming KB211899