LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default The Error That Stumps Me

SinglePercentChange = (csng(AddColumn1FieldRange.Offset _
(RowVal1, ColVal1).Value) / csng( AddColumn1FieldRange.Offset _
(RowVal2, ColVal2)) - 1!) * 100!

--
Regards,
Tom Ogilvy


Alex A wrote in message
...
I am getting this error:
Run-time error '6': Overflow

This is the line of code that is trying to calculate the
division of two fields on the Excel Spreadsheet, then
subract 1 and then multiply by 100: I set up the
variable SinglePercentChange as Single. But still I get
that error message.

SinglePercentChange = (AddColumn1FieldRange.Offset
(RowVal1, ColVal1).Value / AddColumn1FieldRange.Offset
(RowVal2, ColVal2) - 1) * 100

TargetRange.Offset(intRowIndex3, ColumnCountIVSLH2).Value
= SinglePercentChange

Anyone got the VB Kung foo move for this?
Thanks.
Alex

Below is the relevant block of code:

'Return PercentChange Column
intLastRowIndexIVSLH2 = intRowCountIVSLH2 +
TargetRange.Row - 1
intLastRowEndIVSLH2 = intRowCountIVSLH2 - 1 'Never could
figure out why this needs to be -1.

LoopCounter1 = 0
RowVal1 = 0
ColVal1 = -1
RowVal2 = -1
ColVal2 = -1

For intRowIndex3 = (intFirstRowStartIVSLH2 + 1) To
intLastRowEndIVSLH2 Step 1

If LoopCounter1 = 1 Then
Set AddColumn1FieldRange = TargetRange.Offset
(intRowIndex3, intColumnCountIVSLH2)
SinglePercentChange = (AddColumn1FieldRange.Offset
(RowVal1, ColVal1).Value / AddColumn1FieldRange.Offset
(RowVal2, ColVal2) - 1) * 100
TargetRange.Offset(intRowIndex3,
intColumnCountIVSLH2).Value = SinglePercentChange
LoopCounter1 = LoopCounter1 + 1

Else
TargetRange.Offset(intRowIndex3,
intColumnCountIVSLH2).Value = "N/A"
LoopCounter1 = LoopCounter1 + 1
End If

Next intRowIndex3



 
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
Excel 2007 - error saving file & error loading dll TinaF Excel Discussion (Misc queries) 0 July 1st 09 01:49 PM
Counting instances of found text (Excel error? Or user error?) S Davis Excel Worksheet Functions 5 September 12th 06 04:52 PM
Excel 2003 Macro Error - Runtime error 1004 Cow Excel Discussion (Misc queries) 2 June 7th 05 01:40 PM
Error 50290: Error writing to Worksheet while using an ActiveX Control emblair3 Excel Programming 3 February 24th 04 06:03 PM


All times are GMT +1. The time now is 09:33 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"