SOLVED

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!

SteveDatz_0-1647274279647.png


Only relevant info I found seems to be here:
https://support.microsoft.com/en-us/office/how-to-correct-a-num-error-f5193bfc-4400-43f4-88c4-8e1dcc...

SteveDatz_1-1647274323557.png


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

SteveDatz_2-1647274382485.png

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)
Solution

@SteveDatz 

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

@SteveDatz 

That is correct. See Data type summary