Skip to content

Latest commit

 

History

History
41 lines (27 loc) · 2.23 KB

duplicate-declaration-in-current-scope.md

File metadata and controls

41 lines (27 loc) · 2.23 KB
title keywords f1_keywords ms.assetid ms.date ms.localizationpriority
Duplicate declaration in current scope
vblr6.chm1011221
vblr6.chm1011221
55b4c056-c787-b30a-bc8c-30e552a3cdbb
06/08/2017
medium

Duplicate declaration in current scope

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 different procedures, 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 the constant 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 of referenced 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).

[!includeSupport and feedback]