Ambiguous Name Detected VBA

Written by

Mel Jenkins

Reviewed by

Steve Rynearson

Last updated on May 2, 2022

This article will explain the reason that an ambiguous name is detected in VBA.

vba ambiguous intro

There are a number of different reasons why this error can occur in VBA. This is usually due to the fact that a variable and a procedure (sub or function) are called the same within the same scope in your code; of you have 2 procedures that have the same name within the same scope.

Variable and Procedure with Same Name

This error also occur if you have a variable and procedure in the same module with the same name.

To resolve the issue, (1) rename either the the variable and then, (2) in the menu, click Debug > Compile VBA Project to make sure your code will compile.

vba ambiguous changevariable

You will know your code is compiled correctly if the compile option is then greyed out.

vba ambiguous compiled

 

Duplicate Functions or Sub-Procedures

This error will also occur if you have 2 procedures with the same name in the same module, when you try and compile your code, you will get the compile error  – Ambiguous name detected.

vba ambiguous 2 procedures

Removing one of the procedures or amending the name, and then recompiling the code will once again fix the error.

 

vba-free-addin

VBA Code Examples Add-in

Easily access all of the code examples found on our site.

Simply navigate to the menu, click, and the code will be inserted directly into your module. .xlam add-in.

(No installation required!)

Free Download

Return to VBA Code Examples