Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 18
Default Help! Cannot calculate 123 * 456

Tracked the problem down to a single type of calculation that fails,
even in the debug screen.

Try entering in immediate mode:

? 123 * 456

Any easy ways to avoid runtime error 6 with sums of this type? I don't
want to start creating variables, constants etc in a section of code
that performs a long series of simple pre-set calculations that need
to be 'human readable'.

Thanks everyone!

Using Excel 2003 vba.
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 510
Default Help! Cannot calculate 123 * 456

Hi

It looks like VBA decides which data type to use for answer by source
numbers. As both 123 and 456 are interpreted as integers, the result will be
integer too. Integer data type is limited to range -32 768 - 32 767 , but
your result falls outside of it.

Use
? 123.0 * 456
or
? 123 * 456.0 instead


--
Arvi Laanemets
( My real mail address: arvi.laanemets<attarkon.ee )



"Duncan" wrote in message
...
Tracked the problem down to a single type of calculation that fails,
even in the debug screen.

Try entering in immediate mode:

? 123 * 456

Any easy ways to avoid runtime error 6 with sums of this type? I don't
want to start creating variables, constants etc in a section of code
that performs a long series of simple pre-set calculations that need
to be 'human readable'.

Thanks everyone!

Using Excel 2003 vba.



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,600
Default Help! Cannot calculate 123 * 456

An Integer is reserved for the result, but the calculation exceeds +/-32k
causing an overflow error.

Append either or both those numbers with an & to coerce to a Long, eg

? 123& * 456

Regards,
Peter T



"Duncan" wrote in message
...
Tracked the problem down to a single type of calculation that fails,
even in the debug screen.

Try entering in immediate mode:

? 123 * 456

Any easy ways to avoid runtime error 6 with sums of this type? I don't
want to start creating variables, constants etc in a section of code
that performs a long series of simple pre-set calculations that need
to be 'human readable'.

Thanks everyone!

Using Excel 2003 vba.



  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 10,593
Default Help! Cannot calculate 123 * 456

? Clng(123) * 456

--
HTH

Bob

(there's no email, no snail mail, but somewhere should be gmail in my addy)

"Duncan" wrote in message
...
Tracked the problem down to a single type of calculation that fails,
even in the debug screen.

Try entering in immediate mode:

? 123 * 456

Any easy ways to avoid runtime error 6 with sums of this type? I don't
want to start creating variables, constants etc in a section of code
that performs a long series of simple pre-set calculations that need
to be 'human readable'.

Thanks everyone!

Using Excel 2003 vba.



  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 18
Default Help! Cannot calculate 123 * 456

On 12 Sep, 11:32, "Bob Phillips" wrote:
? Clng(123) * 456

--
HTH

Bob

(there's no email, no snail mail, but somewhere should be gmail in my addy)

"Duncan" wrote in message

...

Tracked the problem down to a single type of calculation that fails,
even in the debug screen.


Try entering in immediate mode:


? 123 * 456


Any easy ways to avoid runtime error 6 with sums of this type? I don't
want to start creating variables, constants etc in a section of code
that performs a long series of simple pre-set calculations that need
to be 'human readable'.


Thanks everyone!


Using Excel 2003 vba.


Thanks everyone. Yet another reason for me to hate Microsoft today.


  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 6
Default Help! Cannot calculate 123 * 456

Why would it be a reason to hate Microsoft? When you are trying to do
something outside of the integer size range without taking the time or effort
to change the data type so the calculation will work. Microsoft is not to
blame for your failure to use proper programming.
Neal

"Duncan" wrote:

On 12 Sep, 11:32, "Bob Phillips" wrote:
? Clng(123) * 456

--
HTH

Bob

(there's no email, no snail mail, but somewhere should be gmail in my addy)

"Duncan" wrote in message

...

Tracked the problem down to a single type of calculation that fails,
even in the debug screen.


Try entering in immediate mode:


? 123 * 456


Any easy ways to avoid runtime error 6 with sums of this type? I don't
want to start creating variables, constants etc in a section of code
that performs a long series of simple pre-set calculations that need
to be 'human readable'.


Thanks everyone!


Using Excel 2003 vba.


Thanks everyone. Yet another reason for me to hate Microsoft today.

  #7   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,934
Default Help! Cannot calculate 123 * 456

That seems kind of a harsh response Neal, especially in light of the fact
that you can type things like these into the Immediate window and get the
expected results...

? 12 & "34"

? 1.4 / 1.7

That last one, which looks like two Singles being divided (in the same way
123/456 looks like two Integers being divided), will happily return a Double
as an answer. Personally, I think the "multiplying two Integers produces an
Integer result" is a programming flaw at the core of VB's calculating and/or
coercion routines. More than likely it stems from when they first created
the VB that VBA eventually was modeled after and which followed the memory
restricted days of BASIC from which VB derives. In those early days, the
only numeric data types were Integer, Single and Double... there was no Long
data type back then (you used Double if you had to handle values greater
than an Integer could handle)... Integer calculations that produced a result
too large to store in an Integer produced an error. I think Microsoft
maintained that error condition in its core calculating engine even after
they added the Long data type to the mix (never going back and adjusting the
core routines to account for it).

--
Rick (MVP - Excel)


"Neal Ostrander" wrote in message
...
Why would it be a reason to hate Microsoft? When you are trying to do
something outside of the integer size range without taking the time or
effort
to change the data type so the calculation will work. Microsoft is not to
blame for your failure to use proper programming.
Neal

"Duncan" wrote:

On 12 Sep, 11:32, "Bob Phillips" wrote:
? Clng(123) * 456

--
HTH

Bob

(there's no email, no snail mail, but somewhere should be gmail in my
addy)

"Duncan" wrote in message

...

Tracked the problem down to a single type of calculation that fails,
even in the debug screen.

Try entering in immediate mode:

? 123 * 456

Any easy ways to avoid runtime error 6 with sums of this type? I
don't
want to start creating variables, constants etc in a section of code
that performs a long series of simple pre-set calculations that need
to be 'human readable'.

Thanks everyone!

Using Excel 2003 vba.


Thanks everyone. Yet another reason for me to hate Microsoft today.


  #8   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,600
Default Help! Cannot calculate 123 * 456

Think I'm more with Neal on this one, particularly as regards the hate
thing, it's just the way it is. If the OP had pressed Help when the error
message came up all would have been explained. Read and absorb for ten
seconds, move on.

It's not just historical Integers, same error occurs with Longs -

? 50000& * 50000

above errors with overflow as result is outside the scope of a Long
(that & isn't necessary to coerce a +32k non-decimal to a Long, included
only for emphasis)

but this works
? 50000# * 50000

Regards,
Peter T


"Rick Rothstein" wrote in message
...
That seems kind of a harsh response Neal, especially in light of the fact
that you can type things like these into the Immediate window and get the
expected results...

? 12 & "34"

? 1.4 / 1.7

That last one, which looks like two Singles being divided (in the same way
123/456 looks like two Integers being divided), will happily return a
Double as an answer. Personally, I think the "multiplying two Integers
produces an Integer result" is a programming flaw at the core of VB's
calculating and/or coercion routines. More than likely it stems from when
they first created the VB that VBA eventually was modeled after and which
followed the memory restricted days of BASIC from which VB derives. In
those early days, the only numeric data types were Integer, Single and
Double... there was no Long data type back then (you used Double if you
had to handle values greater than an Integer could handle)... Integer
calculations that produced a result too large to store in an Integer
produced an error. I think Microsoft maintained that error condition in
its core calculating engine even after they added the Long data type to
the mix (never going back and adjusting the core routines to account for
it).

--
Rick (MVP - Excel)


"Neal Ostrander" wrote in
message ...
Why would it be a reason to hate Microsoft? When you are trying to do
something outside of the integer size range without taking the time or
effort
to change the data type so the calculation will work. Microsoft is not to
blame for your failure to use proper programming.
Neal

"Duncan" wrote:

On 12 Sep, 11:32, "Bob Phillips" wrote:
? Clng(123) * 456

--
HTH

Bob

(there's no email, no snail mail, but somewhere should be gmail in my
addy)

"Duncan" wrote in message

...

Tracked the problem down to a single type of calculation that fails,
even in the debug screen.

Try entering in immediate mode:

? 123 * 456

Any easy ways to avoid runtime error 6 with sums of this type? I
don't
want to start creating variables, constants etc in a section of code
that performs a long series of simple pre-set calculations that need
to be 'human readable'.

Thanks everyone!

Using Excel 2003 vba.

Thanks everyone. Yet another reason for me to hate Microsoft today.





  #9   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 6
Default Help! Cannot calculate 123 * 456

Rick,
I agree my response may have been alitte harsh but I get so tired of people
blaming microsoft for things that they could have controled. The OP stated
"I don't
want to start creating variables, constants etc". To me this make the
problem a human one not a software or microsoft one. If your going to take
the time to program something do it correctly, or don't expect the results to
be what you want.

I do appreciate the examples you gave as they helped me to understand an
issue I was having.
Neal

"Rick Rothstein" wrote:

That seems kind of a harsh response Neal, especially in light of the fact
that you can type things like these into the Immediate window and get the
expected results...

? 12 & "34"

? 1.4 / 1.7

That last one, which looks like two Singles being divided (in the same way
123/456 looks like two Integers being divided), will happily return a Double
as an answer. Personally, I think the "multiplying two Integers produces an
Integer result" is a programming flaw at the core of VB's calculating and/or
coercion routines. More than likely it stems from when they first created
the VB that VBA eventually was modeled after and which followed the memory
restricted days of BASIC from which VB derives. In those early days, the
only numeric data types were Integer, Single and Double... there was no Long
data type back then (you used Double if you had to handle values greater
than an Integer could handle)... Integer calculations that produced a result
too large to store in an Integer produced an error. I think Microsoft
maintained that error condition in its core calculating engine even after
they added the Long data type to the mix (never going back and adjusting the
core routines to account for it).

--
Rick (MVP - Excel)


"Neal Ostrander" wrote in message
...
Why would it be a reason to hate Microsoft? When you are trying to do
something outside of the integer size range without taking the time or
effort
to change the data type so the calculation will work. Microsoft is not to
blame for your failure to use proper programming.
Neal

"Duncan" wrote:

On 12 Sep, 11:32, "Bob Phillips" wrote:
? Clng(123) * 456

--
HTH

Bob

(there's no email, no snail mail, but somewhere should be gmail in my
addy)

"Duncan" wrote in message

...

Tracked the problem down to a single type of calculation that fails,
even in the debug screen.

Try entering in immediate mode:

? 123 * 456

Any easy ways to avoid runtime error 6 with sums of this type? I
don't
want to start creating variables, constants etc in a section of code
that performs a long series of simple pre-set calculations that need
to be 'human readable'.

Thanks everyone!

Using Excel 2003 vba.

Thanks everyone. Yet another reason for me to hate Microsoft today.



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
calculate time does not calculate Wanna Learn Excel Discussion (Misc queries) 4 August 19th 08 12:51 AM
Activesheet.Calculate failing to calculate Daniel Bonallack Excel Programming 2 October 11th 06 03:16 AM
How do I calculate IRR? cs Excel Worksheet Functions 1 January 21st 05 09:54 PM
Re calculate libby Excel Programming 1 December 10th 03 04:24 PM
Macro that hide or unhide and not calculate or calculate Jonsson Excel Programming 1 August 19th 03 04:22 PM


All times are GMT +1. The time now is 05:38 PM.

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

About Us

"It's about Microsoft Excel"