Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 208
Default Overflow Error


Ok, I've tried everything. I can't figure out why this is giving me an
overflow error. I've tried every combination I can think of. Changing dim
datatypes, forcing datatypes... nothing works. I have the following code:

Dim varSum As Integer, varCount As Integer
Dim ScoringAve As Double
Dim i As Integer
For i = 1 To 18
If Me.Controls(ScoreBox(i)).Text < "" Then
varSum = varSum + Me.Controls(ScoreBox(i)).Text
varCount = varCount + 1
End If
Next

.Cells(LastRow + 1, 30) = (CLng(varSum) / CLng(varCount))

Every combination gives me Overflow errors. How do I fix this?!
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 9,101
Default Overflow Error



Dim varSum As Integer, varCount As Integer
Dim ScoringAve As Double
Dim MyNumber as Variant
Dim i As Integer
For i = 1 To 18
If Me.Controls(ScoreBox(i)).Text < "" Then
MyNumber = Me.Controls(ScoreBox(i)).Text
if isnumeric(MyNumber) then
varSum = varSum + Val(MyNumber)
varCount = varCount + 1
end if
End If
Next

.Cells(LastRow + 1, 30) = (CLng(varSum) / CLng(varCount))
"Bishop" wrote:

Ok, I've tried everything. I can't figure out why this is giving me an
overflow error. I've tried every combination I can think of. Changing dim
datatypes, forcing datatypes... nothing works. I have the following code:

Dim varSum As Integer, varCount As Integer
Dim ScoringAve As Double
Dim i As Integer
For i = 1 To 18
If Me.Controls(ScoreBox(i)).Text < "" Then
varSum = varSum + Me.Controls(ScoreBox(i)).Text
varCount = varCount + 1
End If
Next

.Cells(LastRow + 1, 30) = (CLng(varSum) / CLng(varCount))

Every combination gives me Overflow errors. How do I fix this?!

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 8,520
Default Overflow Error


Since it is not a type mismatch error I hope you have numeric values in your
text boxes. So changing the type of sum variable should work..as below..

Dim varSum As Variant, intCount As Integer
Dim ScoringAve As Double
Dim i As Integer
For i = 1 To 18
If Isnumeric("0" & Trim(Me.Controls(ScoreBox(i)).Text)) Then
varSum = varSum + ("0" & Me.Controls(ScoreBox(i)).Text)
intCount = intCount + 1
End If
Next


If this post helps click Yes
---------------
Jacob Skaria


"Bishop" wrote:

Ok, I've tried everything. I can't figure out why this is giving me an
overflow error. I've tried every combination I can think of. Changing dim
datatypes, forcing datatypes... nothing works. I have the following code:

Dim varSum As Integer, varCount As Integer
Dim ScoringAve As Double
Dim i As Integer
For i = 1 To 18
If Me.Controls(ScoreBox(i)).Text < "" Then
varSum = varSum + Me.Controls(ScoreBox(i)).Text
varCount = varCount + 1
End If
Next

.Cells(LastRow + 1, 30) = (CLng(varSum) / CLng(varCount))

Every combination gives me Overflow errors. How do I fix this?!

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
overflow error Brad Excel Programming 4 April 2nd 09 10:39 PM
Overflow error Grd Excel Programming 1 January 21st 06 08:13 AM
Overflow Error DG Excel Programming 3 April 15th 05 05:45 PM
Help! Overflow Error 6 Gauthier Excel Programming 6 September 24th 04 12:57 PM
overflow error ExcelMonkey[_5_] Excel Programming 6 January 22nd 04 02:34 AM


All times are GMT +1. The time now is 04:40 AM.

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"