Microsoft KB Archive/175795

= MacXL: Run-Time Error When You Set RowSource Property =

Article ID: 175795

Article Last Modified on 1/22/2007

-

APPLIES TO


 * Microsoft Excel 2001 for Mac
 * Microsoft Excel 98 for Macintosh

-



This article was previously published under Q175795



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 user form.

The RowSource property is not available in the versions of Microsoft Excel listed at the beginning of this article.



WORKAROUND
Microsoft provides programming examples for illustration only, without warranty either expressed or implied. This includes, but is not limited to, the implied warranties of merchantability or fitness for a particular purpose. This article assumes that you are familiar with the programming language that is being demonstrated and with the tools that are used to create and to 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 requirements.

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

The following example adds values that are stored on a worksheet to a ListBox or ComboBox control on a user form:  Save and close any open workbooks and create a new workbook.  Enter the following values into Sheet1:      A1: Item1 A2: Item2 A3: Item3 A4: Item4  Start the Visual Basic Editor (press OPTION+F11). On the Insert menu, click UserForm. Click ListBox in the Toolbox, and draw a list box on the user form. Double-click the user form to open the Code window for the user form.</li>  Type the following code into the module sheet: Private Sub UserForm_Initialize

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

End Sub </li> Run the user form.</li></ol>

The ListBox control is populated with the values from Sheet1.

<div class="references_section">