Fixing Run-Time Error 6 Overflow

dreamingazure

New Member
Joined
May 13, 2010
Messages
4
I have a macro that I have been running successfully for several months now. All of a sudden I'm getting a Run-time 6 overflow message. All I'm doing is pulling a single staff members data from my master list. The Master sheet only has 500 lines of data on it....

Here is the Macro:
Option Explicit
Const msEventColumn As String = "C"
Const msSourceColumns As String = ",G,F,D,E,H,I,J,K,L,M,N,O,P,Q,R,S,T,U,V,W,Z,AA,B,A"
Sub Julie()
Dim iPtr As Long
Dim lTargetRow As Long
Dim rCur As Range
Dim sFirstAddress As String
Dim saSourceCols() As String
Dim vaData() As Variant
Dim wsFrom As Worksheet, wsTo As Worksheet
Set wsFrom = Sheets("Master")
Set wsTo = Sheets("Julie Kennedy")
lTargetRow = wsTo.Cells(Rows.Count, "A").End(xlUp).Row
saSourceCols = Split(msSourceColumns, ",")
ReDim vaData(1 To 1, 1 To UBound(saSourceCols))
With wsFrom.Columns(msEventColumn)
Set rCur = .Find("Julie Kennedy", LookIn:=xlValues)
If Not rCur Is Nothing Then
sFirstAddress = rCur.Address
Do
For iPtr = 1 To UBound(saSourceCols)
vaData(1, iPtr) = wsFrom.Cells(rCur.Row, saSourceCols(iPtr)).Value
Next iPtr
lTargetRow = lTargetRow + 1
wsTo.Range("A" & lTargetRow, Cells(lTargetRow, UBound(vaData, 2)).Address).Value = vaData
Set rCur = .FindNext(rCur)
If rCur Is Nothing Then Exit Do
Loop While rCur.Address <> sFirstAddress
End If
End With
End Sub

When I debug it pulls this up:

Set wsTo = Sheets("Julie Kennedy")
lTargetRow = wsTo.Cells(Rows.Count, "A").End(xlUp).Row
saSourceCols = Split(msSourceColumns, ",")
ReDim vaData(1 To 1, 1 To UBound(saSourceCols))
With wsFrom.Columns(msEventColumn)
Set rCur = .Find("Julie Kennedy", LookIn:=xlValues)
If Not rCur Is Nothing Then
sFirstAddress = rCur.Address
Do
For iPtr = 1 To UBound(saSourceCols)
vaData(1, iPtr) = wsFrom.Cells(rCur.Row, saSourceCols(iPtr)).Value
Next iPtr
lTargetRow = lTargetRow + 1
wsTo.Range("A" & lTargetRow, Cells(lTargetRow, UBound(vaData, 2)).Address).Value = vaData
Set rCur = .FindNext(rCur)
If rCur Is Nothing Then Exit Do
Loop While rCur.Address <> sFirstAddress
End If
End With
End Sub

The code in red is what debug points out...Help?!?!?!
 

Excel Facts

Bring active cell back into view
Start at A1 and select to A9999 while writing a formula, you can't see A1 anymore. Press Ctrl+Backspace to bring active cell into view.
don't know really, but overflow errors usually occur when trying to set a variable with a value of the wrong data type depending on how it is Dim'd.

I suggest you check what is actually in the cell at the time.
 
Upvote 0

Forum statistics

Threads
1,214,622
Messages
6,120,576
Members
448,972
Latest member
Shantanu2024

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