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?!?!?!
 

Some videos you may like

Excel Facts

Last used cell?
Press Ctrl+End to move to what Excel thinks is the last used cell.

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.
 

Subscribe on YouTube

Watch MrExcel Video

Forum statistics

Threads
1,106,458
Messages
5,511,497
Members
408,853
Latest member
JoshuaHudsonpTi45

This Week's Hot Topics

  • Turn fraction around
    Hello I need to turn a fraction around, for example I have 1/3 but I need to present as 3/1
  • TIme Clock record reformatting to ???
    Hello All, I'd like some help formatting this (Tbl-A)(Loaded via Power Query) [ATTACH type="full" width="511px" alt="PQdata.png"]22252[/ATTACH]...
  • TextBox Match
    hi, I am having a few issues with my code below, what I need it to do is when they enter a value in textbox8 (QTY) either 1,2 or 3 the 3 textboxes...
  • Using Large function based on Multiple Criteria
    Hello, I can't seem to get a Large formula to work based on two criteria's. I can easily get a oldest value based one value, but I'm struggling...
  • Can you check my code please
    Hi, Im going round in circles with a Compil Error End With Without With Here is the code [CODE=rich] Private Sub...
  • Combining 2 pivot tables into 1 chart
    Hello everyone, My question sounds simple but I do not know the answer. I have 2 pivot tables and 2 charts that go with this. However I want to...
Top