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

Waterfall charts in Excel?
Office 365 customers have access to Waterfall charts since late 2016. They were added to Excel 2019.

BrianB

Well-known Member
Joined
Feb 17, 2003
Messages
8,127
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.
 

Watch MrExcel Video

Forum statistics

Threads
1,133,037
Messages
5,656,519
Members
418,312
Latest member
jayad

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
Top