Article ID: 157407
Article Last Modified on 11/23/2006
APPLIES TO
- Microsoft Excel 97 Standard Edition
This article was previously published under Q157407
SYMPTOMS
When you run a macro in Microsoft Excel 97, you may receive the following
error message:
Run-time error '424':
Object required
and the macro ends.
CAUSE
This problem may occur when all of the following conditions are true:
- You pass an object, such as a drop-down list, to a subroutine.
-and-
- You do not use the Call statement in the statement that calls the
subroutine
-and-
- You enclose the object that is being passed in parentheses in the
statement that calls the subroutine.
NOTE: This problem does not occur in Microsoft Excel 5.0 and 7.0.
RESOLUTION
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 a Microsoft Certified Partner or the Microsoft fee-based
consulting line at (800) 936-5200. For more information about Microsoft Certified
Partners, please visit the following Microsoft Web site:
For more information about the support options that are available and about how to contact Microsoft, visit the following Microsoft Web site:
The following subroutine generates a run-time error in Microsoft Excel 97:
Sub Passing_Routine()
'Pass the drop-down object that is on Sheet1 of your workbook
'to the subroutine called "Populate_Dropdown"
Populate_Dropdown (Sheets("sheet1").DropDowns("Drop Down 1"))
End Sub
'-------------------------------------------------------------------
'This is the subroutine that is being called by the above subroutine
'and takes the drop-down that is being passed as its argument.
Sub Populate_Dropdown(mydropdown as DropDown)
mydropdown.List = Array("a", "b", "c")
End Sub
To resolve this problem, use either of the following methods.
Method 1
Use the Call statement to call the subroutine. For example, the following
macro illustrates how to call the subroutine Populate_Dropdown:
Sub Passing_Routine()
'Pass the drop-down object that is on Sheet1 of your workbook
'to the subroutine called "Populate_Dropdown".
Call Populate_Dropdown (Sheets("sheet1").DropDowns("Drop Down 1"))
End Sub
Method 2
Remove the parentheses that are around the object that is passed to the
subroutine. In the following example, the parentheses are removed:
Sub Passing_Routine()
'Pass the drop-down object that is on Sheet1 of your workbook
'to the subroutine called "Populate_Dropdown".
Populate_Dropdown Sheets("sheet1").DropDowns("Drop Down 1")
End Sub
STATUS
Microsoft has confirmed this to be a problem in the Microsoft products
listed at the beginning of this article.
Additional query words: XL97 dropdown drop down byref byval parameter
Keywords: kbdtacode kberrmsg kbprogramming KB157407