Quantcast
Channel: Recent Questions - Stack Overflow
Viewing all articles
Browse latest Browse all 17915

CType conversion Integer into Enum type fails

$
0
0
Public Enum EMailType  VornamexNachname  VxNachname  NachnameEnd EnumFunction NoOfContacts(rr As Range, no As Integer) As Variant' determines the number of contacts of type tt w/i range rr;    Dim ...    Dim tt As EMailType    tt = CType(no, EMailType)

results in an error message:

"Error on Compilation - Sub or Function undefined"
(in German: "Fehler beim Kompilieren: Sub oder Funktion nicht definiert")

How can I convert an integerto an Enum type?

I am trying to achieve the conversion of the Integer <no> into the Enum type <tt>!

The trouble is that I am trying to call the function NoOfContacts from the Excel sheet.
Now, originally, instead of <no as Integer>, I used <tt as EMailType> in the function header,

Function NoOfContacts(rr As Range, tt As EMailType) As Variant

however, calling that function from the Excel Sheet resulted in endless errors - most likely because Excel cannot interpret Enum types defined within a VBA module.

So I need either the conversion Integer --> Enum Type or a way to call a function with Enum Types from the Excel main sheet.


Viewing all articles
Browse latest Browse all 17915

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>