Andy Pope
See this msdn article,
http://support.microsoft.com/default.aspx scid=kb;en-us;177991
Especially part F
The maximum number of elements in the array is limited by available memory
or the Excel worksheet maximum size (65536 rows X 256 columns). However,
the maximum number of elements in the array that you can pass to Excel
using the Excel Transpose function is 5461. If you exceed this limit, you
receive the following error message:
Run-time error '13':
Type Mismatch
So to get around the problem short term load both all data and the first column only into arrays.
Use the MATCH function instead to locate the row and the extract the data from the complete array. Obviously this too will error in xl2000 if there are more than 5461 rows.
If that is the case then maybe keep the workbook open and use Range objects to do the VLOOKUP.
Revised code snippet.
Workbooks.Open (OldFN)
OldLastRow = Range("A65536").End(xlUp).Row ' last used row of old sheet
vDataRange = Range("A2", Cells(OldLastRow, 31))
vRange = Range("A2", Cells(OldLastRow, 1))
' close the selected workbook
ActiveWorkbook.Close False, OldFN
' get the last row number on current sheet
LastRow = Range("A65536").End(xlUp).Row
' do a vlookup between the current and old sheet for allocated cases on all rows
For i = 2 To LastRow
' select the next row based on loop
vstring = "A" & i
If IsError(Application.Match(Range(vstring).Value, vRange, 0)) Then
Y = "NEW"
Else
Y = vDataRange(Application.Match(Range(vstring).Value, vRange, 0), 31)
End If
' write the result to the active workbook
Cells(i, 31).Value = Y
Next i