View Single Post
  #6   Report Post  
Posted to microsoft.public.excel.programming
MichaelDavid MichaelDavid is offline
external usenet poster
 
Posts: 100
Default Overflow Error But Right Answer is Produced

Hi Ryan,

In a flash of programming inspiration, I noticed that some of my variables
were declared as Single Precision. So quickly, I did a Ctrl+H and replaced
all "Dim ... As Single" to "Dim ... As Double" thruout all my macros. I then
commented out the On Error Resume Next and On Error GoTo 0 as shown below. I
then ran this macro umpteen times and the overflow error no longer occurs.
Ray!!!

Dim NumShares As Double
Dim NumSharesLong As Long
' On Error Resume Next
NumShares = Round(aNumShrs(lRow, 1), 2)
NumSharesLong = NumShares
' On Error GoTo 0
If aPrice(lRow, 1) - MaxPrice 0# Then MaxPrice = aPrice(lRow, 1)
TotalPurchases = TotalPurchases + aPrice(lRow, 1) * aNumShrs(lRow, 1)
TotalSharesPurchased = TotalSharesPurchased + NumSharesLong

Sincerely,

Michael