Ambiguous name detected
The identifier conflicts with another identifier or requires qualification. This error has the following causes and solutions:
More than one object in the same scope may have elements with the same name.
Qualify the element name by including the object name and a period. For example:
Module-level identifiers and project-level identifiers (module names and referenced project names) may be reused in a procedure, although it makes programs harder to maintain and debug. However, if you want to refer to both items in the same procedure, the item having wider scope must be qualified. For example, if
MyIDis declared at the module level of
MyModule, and then a procedure-level variable is declared with the same name in the module, references to the module-level variable must be appropriately qualified:
Dim MyID As String Sub MySub MyModule.MyID = "This is module-level variable" Dim MyID As String MyID = "This is the procedure-level variable" Debug.Print MyID Debug.Print MyModule.MyID End Sub
An identifier declared at module-level conflicts with a procedure name. For example, this error occurs if the variable
MyIDis declared at module level, and then a procedure is defined with the same name:
Public MyID Sub MyID '. . . End Sub
In this case, you must change one of the names because qualification with a common module name would not resolve the ambiguity. Procedure names are Public by default, but variable names are Private unless specified as Public.
For additional information, select the item in question and press F1 (in Windows) or HELP (on the Macintosh).
Support and feedback
Have questions or feedback about Office VBA or this documentation? Please see Office VBA support and feedback for guidance about the ways you can receive support and provide feedback.