How to change max number of VBA function

Occasional Contributor

Hello I wrote a custom function in excel,

but when I use large numbers (250,000) it comes back as #=NUM!


Only relevant info I found seems to be here:


Yet I have absolutely no idea how or where to do that. 
Clicking on "show calculations steps" just shows me this.


I tried changing from an INTEGER to a DOUBLE, but 250,000 should clearly fit inside of an integer.. so im really confused

3 Replies
best response confirmed by SteveDatz (Occasional Contributor)


The range of Integer is -32768 to +32767.

Use Double or Currency for BaseCost, and Long for NumOwned.

Okay interesting, thanks so Integer, double, long etc.. in excel is not even close to what it is in other programming languages ?? for example in C# an int is = 2,147,483,647


That is correct. See Data type summary