Quantcast
Channel: Excel Help Forum - Excel Programming / VBA / Macros
Viewing all articles
Browse latest Browse all 50079

Enum: use same user-defined name in 2 Enum's

$
0
0
Hi,

I found out that using Enum one can have a dropdown box to choose from when inserting a parameter in a function.
enum drop-down.jpg

But how can I have the same user-defined constant in more then one Enum?
It works with standard VBA variables like vbEmpty, so why not with self made constants?

I tried this which gives the error: Ambiguous name detected
Code:

Private Const vbTest = 99 ''' = Ambiguous name detected !!!

Enum eTest1 '''gives 3 choices
    vbEmpty        ''' = standard VBA 1
    vbLong          ''' = standard VBA 3
    vbTest          ''' not in VBA, so I would assign 99 to it
End Enum

Enum eTest2 '''gives only 2 choices
    vbEmpty        ''' = standard VBA 1
    vbTest          ''' = Ambiguous name detected !!!
End Enum

and I tried this which gives again the error: Ambiguous name detected
Code:

Enum eTest1 '''gives 3 choices
    vbEmpty        ''' = standard VBA 1
    vbLong          ''' = standard VBA 3
    vbTest = 99    ''' not in VBA, so I would assign 99 to it
End Enum

Enum eTest2 '''gives only 2 choices
    vbEmpty        ''' = standard VBA 1
    vbTest = 99    ''' = Ambiguous name detected !!!
End Enum

Any way I can solve this?

thank you.

Viewing all articles
Browse latest Browse all 50079

Trending Articles