XL98: Setting RowSource Property Results in Run-Time Error

ID: Q175795

The information in this article applies to:

SYMPTOMS

When you run a Visual Basic for Applications macro, you may receive the following error message:

   Run-time error '380:'
   Could not set the RowSource property. Invalid property value.

CAUSE

This error occurs when you attempt to programmatically set the RowSource property of a ListBox or ComboBox control on a UserForm.

The RowSource property is not available in Microsoft Excel 98 Macintosh Edition.

WORKAROUND

To work around this behavior, store the values in a worksheet, and then use a Visual Basic for Applications procedure to populate the control.

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 professionals 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/supportnet/refguide/ 

The following example adds values that are stored on a worksheet to a ListBox or ComboBox control on a UserForm:

1. Save and close any open workbooks and create a new workbook.

2. Enter the following values into Sheet1:

      A1: Item1
      A2: Item2
      A3: Item3
      A4: Item4

3. Start the Visual Basic Editor (press OPTION+F11).

4. On the Insert menu, click UserForm.

5. Click ListBox on the Toolbox, and draw a ListBox on the UserForm.

6. Double-click the UserForm to open the Code window for the UserForm.

7. Type the following code into the module sheet:

      Private Sub UserForm_Initialize()

         ListBox1.List = Worksheets("Sheet1").Range("A1:A5").Value

      End Sub

8. Run the UserForm.

The ListBox control is populated with the values from Sheet1.

STATUS

This behavior is by design of Microsoft Excel.

REFERENCES

For more information about using the ListBox control, click the Office Assistant, type "Listbox," click Search, and then click to view "ListBox Control."

For more information about using the ComboBox control, click the Office Assistant, type "Combobox," click Search, and then click to view "ComboBox Control."

NOTE: If the Assistant is hidden, click the Office Assistant button on the Standard toolbar. If Microsoft Help is not installed on your computer, please see the following article in the Microsoft Knowledge Base:

   ARTICLE-ID: Q179216
   TITLE     : Off98: How to Use the Microsoft Office Installer Program

Additional query words: XL98
Keywords          : kbprg xlvbainfo kbfaq
Version           : MACINTOSH:98
Platform          : MACINTOSH
Hardware          : MAC
Issue type        : kbprb

Last Reviewed: May 18, 1999