That code declares the variable nomeMenu three times.
1)Inside the sub AddMenus, remove the line
2)Change the name of the argument in DeleteMenu, e.g.
3)The typemismatch is coming from the module wide declaration (before AddMenus) of nomeMenu. In ThisWorkbook, nomeMenu is not declared and therefore assumed to be a Variant rather than a String. Hence the type mismatch.
To fix that, set your VBEditor Preferences to Require Variable Declaration. This will put Option Explicit at the start of all your modules and prevent future problems.
For this specific situation, changing the first line in the posted code to
will give nomeMenu a global scope and set things right.
Bookmarks