Run Time Error 6: Overflow Error

ceytl

Board Regular
Joined
Jun 6, 2009
Messages
114
Office Version
  1. 2016
Platform
  1. Windows
Hello, when I run the below code I get: Run Time Error 6: Overflow Error

Any idea on why this is happening?

Thanks!

VBA Code:
Sub CopyNumber()

Dim rownum As Long
Dim sht As Worksheet
Dim myval As Long

Set sht = ActiveSheet
rownum = 1

Do Until rownum = sht.Cells(sht.Rows.Count, "T").End(xlUp).row + 1
    If IsNumeric(sht.Range("T" & rownum)) = True Then
    myval = Range("T" & rownum)
    rownum2 = rownum
        If sht.Range("K" & rownum2) = "PA" Then
            Do Until sht.Range("I" & rownum2) = "Name No.:"
                rownum2 = rownum2 + 1
            Loop
        sht.Range("X" & rownum2) = myval
        End If
    End If
rownum = rownum + 1
Loop


End Sub
 

Excel Facts

Copy PDF to Excel
Select data in PDF. Paste to Microsoft Word. Copy from Word and paste to Excel.
On which line do you get the error?
 
Upvote 0
What line do you get the error on?

One possibility is that column T contains a value too big for a Long datatype:
VBA Code:
myval = Range("T" & rownum)
 
Upvote 0
That’s too big for a long. Use Double or even string since you aren’t doing calculations with it.
 
Upvote 0
Solution

Forum statistics

Threads
1,214,611
Messages
6,120,510
Members
448,967
Latest member
screechyboy79

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top