Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Run-time error '6' overflow

I keep getting that error when I use this code
Sub test()
Dim a As Integer
For a = 50000 To 50100
Range("J1, K28").Value = a
ActiveSheet.PrintOut
Next a
End Sub

but it has always worked perfectly when I used this
Sub test()
Dim a As Integer
For a = 20000 To 20100
Range("J1, K28").Value = a
ActiveSheet.PrintOut
Next a
End Sub

But I can't figure out which part is causing the problem
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 7,247
Default Run-time error '6' overflow

Suzy,

An integer can contain values between +/- 32K, and when you
attempt to store 50000 in the variable 'a', you are overflowing
the capacity of an integer. Change the variable to a Long type.
E.g.,

Dim a As Long

I



"Suzy" wrote in message
...
I keep getting that error when I use this code
Sub test()
Dim a As Integer
For a = 50000 To 50100
Range("J1, K28").Value = a
ActiveSheet.PrintOut
Next a
End Sub

but it has always worked perfectly when I used this
Sub test()
Dim a As Integer
For a = 20000 To 20100
Range("J1, K28").Value = a
ActiveSheet.PrintOut
Next a
End Sub

But I can't figure out which part is causing the problem



  #3   Report Post  
Posted to microsoft.public.excel.programming
No Name
 
Posts: n/a
Default Run-time error '6' overflow

It works perfectly.
Greatly Appreciated
Suzy


-----Original Message-----
Suzy,

An integer can contain values between +/- 32K, and when

you
attempt to store 50000 in the variable 'a', you are

overflowing
the capacity of an integer. Change the variable to a

Long type.
E.g.,

Dim a As Long

I



"Suzy" wrote in

message
...
I keep getting that error when I use this code
Sub test()
Dim a As Integer
For a = 50000 To 50100
Range("J1, K28").Value = a
ActiveSheet.PrintOut
Next a
End Sub

but it has always worked perfectly when I used this
Sub test()
Dim a As Integer
For a = 20000 To 20100
Range("J1, K28").Value = a
ActiveSheet.PrintOut
Next a
End Sub

But I can't figure out which part is causing the

problem


.

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.. why? Fingerjob Excel Discussion (Misc queries) 4 November 13th 06 05:18 PM
runtime error '6' overflow don Setting up and Configuration of Excel 1 July 26th 05 02:52 AM
Overflow Error DG Excel Discussion (Misc queries) 3 April 15th 05 05:45 PM
overflow error ExcelMonkey[_5_] Excel Programming 6 January 22nd 04 02:34 AM
Run-time error 6 Overflow FredM Excel Programming 2 January 20th 04 06:05 AM


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