473,386 Members | 1,609 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

I get a runtime error when trying to run a macro and I would like to know how to fix

Hi, I am getting a message that says Runtime Error '6': Overflow when I run the following code.

How do I fix this?
Expand|Select|Wrap|Line Numbers
  1. Sub GoldCustomersHealthcheck()
  2. Dim i As Integer, MessageString As String
  3.  
  4. MessageString = ""
  5.  
  6. For i = 2 To ActiveSheet.UsedRange.Rows.Count
  7.     If Range("B" & i).Value - Range("C" & i).Value > Range("MaxAbsolute").Value _
  8.         Or (Range("B" & i).Value - Range("C" & i).Value) / Range("B" & i).Value > Range("MaxPercentage").Value Then
  9.  
  10.         MessageString = MessageString & Range("A" & i).Value & ","
  11.     End If
  12. Next i
  13.  
  14. If MessageString <> "" Then
  15.     MessageString = Left(MessageString, Len(MessageString) - 2)
  16.     MsgBox ("These customers exceeded the maximum fall last week:" & vbLf & MessageString)
  17. Else
  18.     MsgBox ("No customers exceeded the maximum fall last week.")
  19. End If
  20.  
  21. End Sub
Thanx!
Oct 29 '13 #1
1 1305
MikeTheBike
639 Expert 512MB
Hi

It would be usfull if you could indicate which line throws the error, but my first guess is that the used range is more than 32k rows, in which case try dimesioning i as long.

??

MTB
Oct 30 '13 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

2
by: Debbie | last post by:
Hi I have developed an application that access an SQL database and installed it on a different machine The installation is successful but when I try to run the application I get the following...
1
by: Jeff Thur | last post by:
I am getting this error when trying to run a stored procedure: Microsoft.VisualBasic.CompilerServices.LateBinding.LateInd exGet(Object o, Object args, String paramnames) +1361...
1
by: Vike_Fan_Forever | last post by:
I am having a problem that looks exactly the same as the below link. ...
5
by: snicks | last post by:
I'm trying to exec a program external to my ASP.NET app using the following code. The external app is a VB.NET application. Dim sPPTOut As String sPPTOut = MDEPDirStr + sID + ".ppt" Dim p As...
1
by: dipesh | last post by:
I am getting error when trying to Add Web Reference in Visual Studio 2005. "Some of the files required for web references are not installed"
2
by: ticars | last post by:
I'm getting a weird error when trying to access a user control from within a base page during runtime. Here's what I have: I have a master page with a user control on it. I then have a few...
3
by: LRI41 | last post by:
I googled an error message and it came up with two posts on your forum and when I got there it said I needed to register to post my question, I am not sure whether is this the correct place to...
2
by: Jim | last post by:
Hello everyone, This is my first time posting to a Usenet group, so please excuse any Netiquette errors I may have in my post. I have used ASP.NET before using C#, but never VB, so I'm trying...
1
by: b singh | last post by:
In iis 7 http:/site/x.aspx/pp%3f is giving runtime error Instaed of invalid virtual path. x.aspx is not existing in the server. What setting of IIS 7 is reuired so that it will give invalid...
2
by: lwmama | last post by:
My daughter has a computer with windows xp installed on it. I recently purchased a game (KNOWLEGE ADVENTURE PRESCOOL). It worked fine for a while but then she started getting into files and stuff she...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.