ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Variable overflow (https://www.excelbanter.com/excel-programming/356233-variable-overflow.html)

Derick Hughes

Variable overflow
 

Is there a way for a large number to be assigned to a variable? For
example:

Dim maxlen as Currency

Sub
maxlen = application.worksheetfunction.combin(60,20)
End sub

maxlen produces an overflow error. Is there a way around this?


Regards
Dk

*** Sent via Developersdex http://www.developersdex.com ***

Nigel

Variable overflow
 
Dim maxlen as Double

--
Cheers
Nigel



"Derick Hughes" wrote in message
...

Is there a way for a large number to be assigned to a variable? For
example:

Dim maxlen as Currency

Sub
maxlen = application.worksheetfunction.combin(60,20)
End sub

maxlen produces an overflow error. Is there a way around this?


Regards
Dk

*** Sent via Developersdex http://www.developersdex.com ***




Tom Ogilvy

Variable overflow
 
use a double. Numbers in the Excel sheet are doubles

from the immediate window:
a = application.combin(60,20)
? a
4.1918445058055E+15

--
Regards,
Tom Ogilvy


"Derick Hughes" wrote:


Is there a way for a large number to be assigned to a variable? For
example:

Dim maxlen as Currency

Sub
maxlen = application.worksheetfunction.combin(60,20)
End sub

maxlen produces an overflow error. Is there a way around this?


Regards
Dk

*** Sent via Developersdex http://www.developersdex.com ***


Daniel

Variable overflow
 
Thanks, Using double still poses a problem. I would using maxlen in a
loop and reducing it by 1 after each iteration.


Regards
Dk

*** Sent via Developersdex http://www.developersdex.com ***

Tom Ogilvy

Variable overflow
 
why would you even think about looping over a number like that. The value
returned by combin only has 15 significant digits, so you are not getting the
exact number any how

Anyway, even if it took 1 millionth of a second to do each loop, it would
take around 132 years to complete the loop. I could be off by a couple of
years.

--
Regards,
Tom Ogilvy


"Daniel" wrote:

Thanks, Using double still poses a problem. I would using maxlen in a
loop and reducing it by 1 after each iteration.


Regards
Dk

*** Sent via Developersdex http://www.developersdex.com ***



All times are GMT +1. The time now is 12:59 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com