Overflow Error Been Replaced with 1004 error


New Member
Dec 8, 2017
So I have a very large worksheets(400000 + in length 8 variables) that have the price for a stock and i want to organize it into a worksheet where all cells are side by side.

I trouble shooted through until I got it to work for about half of the data set until it said overflow error. I check to see if there was an error listed in one of the price files but there didn't seem to be.

Then when I went to debug it came up with a 1004 error on the line that reads;

matrixdate = WorksheetFunction.Match(datelookup, Range("k3:k4260"), 0)

the entire script is below

Sub proZero()

Application.Calculation = xlCalculationManual

Dim off As Integer
Dim datelookup As Variant
Dim comlookup As String
Dim matrixcom As Integer
Dim matrixdate As Variant

off = 1

Do While off < 4219912

datelookup = Range("b1").Offset(off, 0).Value
matrixdate = WorksheetFunction.Match(datelookup, Range("k3:k4260"), 0)

comlookup = Range("c1").Offset(off, 0).Value
matrixcom = WorksheetFunction.Match(comlookup, Range("l2:dn2"), 0)

Range("k2").Offset(matrixdate, matrixcom).Value = Range("g1").Offset(off, 0).Value

off = off + 1

End Sub

any help would be appreciated!!


MrExcel MVP, Junior Admin
Aug 1, 2002
Office Version
One issue I see is with your variable declarations:
[COLOR=#333333]Dim off As Integer[/COLOR]

[COLOR=#333333]off = 1[/COLOR]

[COLOR=#333333]Do While off < 4219912[/COLOR]
The maximum Integer value you can have is 32767.
You need to use "Long" instead.
See: http://www.informit.com/articles/article.aspx?p=339929&seqNum=2

Forum statistics

Latest member
Shahzad Taimoor

Some videos you may like

This Week's Hot Topics

  • populate from drop list with multiple tables
    Hi All, i have a drop list that displays data, what i want is when i select one of those from the list to populate text from different tables on...
  • Find list of words from sheet2 in sheet1 before a comma and extract text vba
    Hi Friends, Trying to find the solution on my task. But did not find suitable one to the need. Here is my query and sample file with details...
  • Dynamic Formula entry - VBA code sought
    Hello, really hope one of you experts can help with this - i've spent hours on this and getting no-where. .I have a set of data (more rows than...
  • Listbox Header
    Have a named range called "AccidentsHeader" Within my code I have: [CODE]Private Sub CommandButton1_Click() ListBox1.RowSource =...
  • Complex Heat Map using conditional formatting
    Good day excel world. I have a concern. Below link have a list of countries that carries each country unique data. [URL...
  • Conditional formatting
    Hi good morning, hope you can help me please, I have cells P4:P54 and if this cell is equal to 1 then i want row O to say "Fully Utilised" and to...