Hi All
I'm new to the forum and hoping to get some help please.
I've got the following code in VBA which I thought would save me alot of time when doing vlookups as it is all being stored in an array. But it still takes A LONG time to run through. Am I doing something wrong here?
Option Explicit
Option Base 1
Sub TestArray()
Dim Data As Variant
Dim Lookup As Variant
Dim i As Integer
Data = Sheets(3).Range("A2:C65536")
Lookup = Sheets(1).Range("J2:J3556")
ReDim Preserve Lookup(UBound(Lookup), 2)
For i = 1 To UBound(Lookup)
Lookup(i, 2) = Application.VLookup(Lookup(i, 1), Data, 3, 0)
If IsError(Lookup(i, 2)) Then Lookup(i, 2) = ""
Application.StatusBar = Format((i / UBound(Lookup)) * 100, "0.00") & "%"
Next i
Application.StatusBar = False
With Sheets(1)
.Range(.Cells(2, 34), .Cells(UBound(Lookup), 34)) = Application.Index(Lookup, , 2)
End With
'Cells.SpecialCells(xlCellTypeConstants, 16).ClearContents 'remove N/A errors
End Sub
Thanks
Bookmarks