Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default units = ActiveCell.Value overflow


The subject pretty much sums it up.
I've got a number in a cell that i want to divide by 3, but for some
reason i keep getting an overflow error when i try to save a number
from a cell into a variable. The variable is an int, and the number
shouldn't be too big to fit.

Thanks for the help,

Chris


--
cbh35711
------------------------------------------------------------------------
cbh35711's Profile: http://www.excelforum.com/member.php...o&userid=30276
View this thread: http://www.excelforum.com/showthread...hreadid=566328

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default units = ActiveCell.Value overflow


Try changing the variable type to Double. Int is not going to accept
your value if it has decimals.


--
Excelenator


------------------------------------------------------------------------
Excelenator's Profile: http://www.excelforum.com/member.php...o&userid=36768
View this thread: http://www.excelforum.com/showthread...hreadid=566328

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default units = ActiveCell.Value overflow

What's the number. What happens if you change the type to Long.

--
Regards,
Tom Ogilvy

"cbh35711" wrote in
message ...

The subject pretty much sums it up.
I've got a number in a cell that i want to divide by 3, but for some
reason i keep getting an overflow error when i try to save a number
from a cell into a variable. The variable is an int, and the number
shouldn't be too big to fit.

Thanks for the help,

Chris


--
cbh35711
------------------------------------------------------------------------
cbh35711's Profile:
http://www.excelforum.com/member.php...o&userid=30276
View this thread: http://www.excelforum.com/showthread...hreadid=566328



  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default units = ActiveCell.Value overflow

Int is not going to accept
your value if it has decimals.



I couldn't reproduce that:

b% = 8/7
? b%
1
? typename(b)
Integer


It certainly won't hold the decimal portion, but that won't cause an
overflow error.

--
Regardes,
Tom Ogilvy



"Excelenator"
wrote in message
...

Try changing the variable type to Double. Int is not going to accept
your value if it has decimals.


--
Excelenator


------------------------------------------------------------------------
Excelenator's Profile:
http://www.excelforum.com/member.php...o&userid=36768
View this thread: http://www.excelforum.com/showthread...hreadid=566328



  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,253
Default units = ActiveCell.Value overflow


You can easily overload a long...

Sub OverKill()
Dim d#, l&
d = 1E+100
l = d
End Sub


--
keepITcool
| www.XLsupport.com | keepITcool chello nl | amsterdam


Tom Ogilvy wrote in

What's the number. What happens if you change the type to Long.



  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default units = ActiveCell.Value overflow


perfect, worked great.

Thanks

Chris


--
cbh35711
------------------------------------------------------------------------
cbh35711's Profile: http://www.excelforum.com/member.php...o&userid=30276
View this thread: http://www.excelforum.com/showthread...hreadid=566328

  #7   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default units = ActiveCell.Value overflow

Really. So they weren't kidding in the help when they said:

Long (long integer) variables are stored as signed 32-bit (4-byte) numbers
ranging in value from -2,147,483,648 to 2,147,483,647

--
Regards,
Tom Ogilvy

"keepITcool" wrote in message
.com...

You can easily overload a long...

Sub OverKill()
Dim d#, l&
d = 1E+100
l = d
End Sub


--
keepITcool
| www.XLsupport.com | keepITcool chello nl | amsterdam


Tom Ogilvy wrote in

What's the number. What happens if you change the type to Long.



  #8   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default units = ActiveCell.Value overflow

You can easily overload a double...

Sub OverflowDouble()
Dim d#
d = CDbl(1E+308) * 2#
End Sub

is that helpful?



--
Regards,
Tom Ogilvy

"keepITcool" wrote in message
.com...

You can easily overload a long...

Sub OverKill()
Dim d#, l&
d = 1E+100
l = d
End Sub


--
keepITcool
| www.XLsupport.com | keepITcool chello nl | amsterdam


Tom Ogilvy wrote in

What's the number. What happens if you change the type to Long.



  #9   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,253
Default units = ActiveCell.Value overflow

Tom, okay i was blunt:)

my point was..
a cell may hold a large floating point value.
even when assigned to a long variable it can overload.
(infamous example: ?cells.count in excel 2007)

Tip for OP:
an integer holds -32768 to +32768 only.
a long holds from -2 to +2 billion.

IN VBA just dont just Integer but Long for al your counters.
the extra bytes dont matter as much as they did in 1980.

--
keepITcool
| www.XLsupport.com | keepITcool chello nl | amsterdam


Tom Ogilvy wrote in

You can easily overload a double...

Sub OverflowDouble()
Dim d#
d = CDbl(1E+308) * 2#
End Sub

is that helpful?

Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Units Produced / (finish time minus start time)=Units Per Hr Gary A Excel Worksheet Functions 1 February 10th 09 01:35 AM
If activecell.column = variable then activecell,offset (0,1) Battykoda via OfficeKB.com Excel Discussion (Misc queries) 1 October 2nd 07 08:05 PM
Overflow Erik Beck Jensen Excel Programming 2 December 13th 05 10:11 AM
VBA overflow Tom Ogilvy Excel Programming 3 September 2nd 03 09:04 PM
VBA overflow Don Guillett[_4_] Excel Programming 2 September 2nd 03 04:19 PM


All times are GMT +1. The time now is 08:44 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"