Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
Kim Kim is offline
external usenet poster
 
Posts: 284
Default runtime error 6 overflow when running a macro

hi. im trying to run a macro and it works perfectly till about row 30,197
then it crashes and gives a runtime 6 error (overflow).

Dim g As Double


For g = b To Sheet1.Rows.Count
If UCase(Trim(Sheet1.Cells(g, nSecondDefnColBegin).Value)) =
firstcell Then
nSecondDefnRow = g
Let b = g
Exit For
End If

Next g

the error happens in the row nSecondDefnRow = g. Any reasons why this
happens? and how can i fix the problem? Thanks.

Kim
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35,218
Default runtime error 6 overflow when running a macro

Did you declare nSecondDefnRow as Integer or Long.

Integer only goes up to 32,767.

Is there a reason to process all 65536 rows?

Maybe you can find the last row (based on the stuff in column A)???

dim LastRow as long

with sheet1
lastrow = .cells(.rows.count,"A").end(xlup).row
end with

for g = b to lastrow
....



Kim wrote:

hi. im trying to run a macro and it works perfectly till about row 30,197
then it crashes and gives a runtime 6 error (overflow).

Dim g As Double


For g = b To Sheet1.Rows.Count
If UCase(Trim(Sheet1.Cells(g, nSecondDefnColBegin).Value)) =
firstcell Then
nSecondDefnRow = g
Let b = g
Exit For
End If

Next g

the error happens in the row nSecondDefnRow = g. Any reasons why this
happens? and how can i fix the problem? Thanks.

Kim


--

Dave Peterson
  #3   Report Post  
Posted to microsoft.public.excel.programming
ADG ADG is offline
external usenet poster
 
Posts: 76
Default runtime error 6 overflow when running a macro

Try change g to data type long instead of Double
--
Tony Green


"Kim" wrote:

hi. im trying to run a macro and it works perfectly till about row 30,197
then it crashes and gives a runtime 6 error (overflow).

Dim g As Double


For g = b To Sheet1.Rows.Count
If UCase(Trim(Sheet1.Cells(g, nSecondDefnColBegin).Value)) =
firstcell Then
nSecondDefnRow = g
Let b = g
Exit For
End If

Next g

the error happens in the row nSecondDefnRow = g. Any reasons why this
happens? and how can i fix the problem? Thanks.

Kim

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 7,247
Default runtime error 6 overflow when running a macro

Kim,

How have you declare your other variables. If you declared one as
Integer, change it to Long.


--
Cordially,
Chip Pearson
Microsoft MVP - Excel
Pearson Software Consulting, LLC
www.cpearson.com

"Kim" wrote in message
...
hi. im trying to run a macro and it works perfectly till about
row 30,197
then it crashes and gives a runtime 6 error (overflow).

Dim g As Double


For g = b To Sheet1.Rows.Count
If UCase(Trim(Sheet1.Cells(g,
nSecondDefnColBegin).Value)) =
firstcell Then
nSecondDefnRow = g
Let b = g
Exit For
End If

Next g

the error happens in the row nSecondDefnRow = g. Any reasons
why this
happens? and how can i fix the problem? Thanks.

Kim



  #5   Report Post  
Posted to microsoft.public.excel.programming
Kim Kim is offline
external usenet poster
 
Posts: 284
Default runtime error 6 overflow when running a macro

Tried that. didn't solve the error.

"ADG" wrote:

Try change g to data type long instead of Double
--
Tony Green


"Kim" wrote:

hi. im trying to run a macro and it works perfectly till about row 30,197
then it crashes and gives a runtime 6 error (overflow).

Dim g As Double


For g = b To Sheet1.Rows.Count
If UCase(Trim(Sheet1.Cells(g, nSecondDefnColBegin).Value)) =
firstcell Then
nSecondDefnRow = g
Let b = g
Exit For
End If

Next g

the error happens in the row nSecondDefnRow = g. Any reasons why this
happens? and how can i fix the problem? Thanks.

Kim

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
runtime error '6' overflow don Setting up and Configuration of Excel 1 July 26th 05 02:52 AM
runtime error '6' overflow don Excel Programming 3 July 26th 05 02:38 AM
Runtime Error 6 Overflow Wescotte Excel Programming 5 June 13th 05 11:59 PM
Excel 2003 Macro Error - Runtime error 1004 Cow Excel Discussion (Misc queries) 2 June 7th 05 01:40 PM
overflow error 6.. the macro just stops any idea why? ste mac Excel Programming 4 February 7th 05 04:00 PM


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