Excel VBA, Can you use Index, Match in VBA without calling Worksheet.Function?

I need to loop through an array, do an index match for tens of thousands of records and the call to worksheet.function is extremely slow. Any way to avoid the slowness or the call altogether?

        Set rTradeId = .Range("B2:B" & lRowsEag)
        avTradeId = rTradeId.Value2
        Set rEntity = .Range("C2:C" & lRowsEag)
        avEntity = rEntity.Value2
        On Error Resume Next
            With WorksheetFunction
                For j = 1 To UBound(avEntity)
                    avEntity(j, 1) = .Index(rTableLch, .Match(avTradeId(j, 1), rShAdmin, 0), 1)
                Next j
            End With
        On Error GoTo 0
        rEntity.Value2 = avEntity
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Not really. It is slow because of the number of functions you are executing.
You could add a column, put the formula in it (through VBA), then copy / paste value and be done. It might be faster.

Have you added the classic speed up tags around your code?

With application
    .ScreenUpdating = False
    .EnableEvents = False
    .Calculation = xlCalculationManual
    .DisplayAlerts = False
End With

'your code

With application
    .ScreenUpdating = True
    .EnableEvents = True
    .Calculation = xlCalculationAutomatic
    .DisplayAlerts = True
End With

Open in new window


Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
newparadigmzAuthor Commented:
That's a bummer, Autofill is faster, but still pretty slow.

It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Microsoft Excel

From novice to tech pro — start learning today.