Table of contents
Collapse the table of content
Expand the table of content

Duplicate declaration in current scope

office 365 dev account|Last Updated: 6/12/2017
1 Contributor

The specified name is already used at this level of scope. For example, two variables can have the same name if they are defined in differentprocedures, but not if they are defined within the same procedure. This error has the following causes and solutions:

  • A new variable or procedure has the same name as an existing variable or procedure. For example:
Sub MySub() 
Dim A As Integer 
Dim A As Variant 
. . .        ' Other declarations or procedure code here. 
End Sub
 Check the current procedure,[module](, or [project]( and remove any duplicate declarations.
  • A Const statement uses the same name as an existing variable or procedure. Remove or rename theconstant in question.

  • You declared a fixed array more than once.

    Remove or rename one of the arrays.

Search for the duplicate name. When specifying the name to search for, omit any type-declaration character because a conflict occurs if the names are the same and the type-declaration characters are different. Note that a module-level variable can have the same name as a variable declared in a procedure, but when you want to refer to the module-level variable within the procedure, you must qualify it with the module name. Module names and the names ofreferenced projects can be reused as variable names within procedures and can also be qualified. For additional information, select the item in question and press F1 (in Windows) or HELP (on the Macintosh).

© 2018 Microsoft