Error 6: Overflow; Dim as long already?

Rogue909

New Member
Joined
Oct 23, 2017
Messages
11
So I have a with loop....

Code:
Dim i As Long

 For i = 1 To 4000        If CalibSource.Cells(i, 1).Value = "1/2/2013" Then
            CalibSource.Range(CalibSource.Cells(i, 1), CalibSource.Cells(i, 15)).Copy
            CalibSh.Range("A" & CalibSh.Cells(Rows.Count, 1).End(xlUp).Row + 1).PasteSpecial Paste:=xlPasteValues
        End If
    Next i

If I change the "For i=1 to 4000" to 5000 (to increase the search range) than I immediately get an error 6 overflow.

My research has indicated that this is because i is not called as an integer... however it clearly is?

What is it that I am missing? Unfortunately I need to have a search range larger than 4000 rows so I need to figure this out.
 
If the cell contains an actual date, you can just refer to its Value/Value2 property directly, no need for DateSerial.
 
Upvote 0

Excel Facts

Move date out one month or year
Use =EDATE(A2,1) for one month later. Use EDATE(A2,12) for one year later.

Forum statistics

Threads
1,216,123
Messages
6,128,975
Members
449,480
Latest member
yesitisasport

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