Alternative to an Index/Match formula

FryGirl

Well-known Member
Joined
Nov 11, 2008
Messages
1,364
Office Version
  1. 365
  2. 2016
Platform
  1. Windows
I'm using VBA to write a formula (CSE) to a sheet with would be applied over a few thousand rows.

=INDEX('UMD Data'!A:A,MATCH(B2&"|"&D2&"|"&"Y",'UMD Data'!D:D&"|"&'UMD Data'!I:I&"|"&'UMD Data'!B:B,0))

Looking at speeding up this process as it really bogs down the processor speed, is there an alternative that could be more efficient?
 

Excel Facts

What is =ROMAN(40) in Excel?
The Roman numeral for 40 is XL. Bill "MrExcel" Jelen's 40th book was called MrExcel XL.
Your biggest problem is the last part of the formula where you're joining the cells of 3 entire columns, reducing that to a range of 10k rows would reduce the processing effort required by ~99%
 
Upvote 0
In VBA, I can establish the last row, but how can I make that part of the formula dynamic to receive the proper range?
 
Upvote 0
Using rng as the range to write the formula to and lRow as the variable for the last row try this one.
VBA Code:
rng.Formula = "=INDEX('UMD Data'!A$2:A" & lRow & ",MATCH(B2&""|""&D2&""|Y"",'UMD Data'!D$2:D" & lRow & "&""|""&'UMD Data'!I$2:I" & lRow & "&""|""&'UMD Data'!B$2:B" & lRow & ",0))"

Only done a quick edit in the forum but not tested it, hopefully I have it right.
 
Upvote 0
As it's an array formula, you need to put it in one cell & then copy down, like
VBA Code:
Sub FryGirl()
   Dim UsdRws As Long
   
   UsdRws = Sheets("UMD Data").Range("A" & Rows.count).End(xlUp).Row
   With Sheets("Sheet1")
      .Range("C2").FormulaArray = "=INDEX('UMD Data'!A$2:A$" & UsdRws & ",MATCH(B2&""|""&D2&""|Y"",'UMD Data'!D$2:D$" & UsdRws & "&""|""&'UMD Data'!I$2:I$" & UsdRws & "&""|""&'UMD Data'!B$2:B$" & UsdRws & ",0))"
      .Range("C2:C" & .Range("B" & Rows.count).End(xlUp).Row).FillDown
   End With
End Sub
 
Upvote 0
Thank you both Jason and Fluff. This works great. Yes, I learned the hard way you can't fill down an array formula the way you do a regular formula.
 
Upvote 0
Glad we could help & thanks for the feedback.
 
Upvote 0
Thanks for picking that up, Fluff. I forgot about the array and wrote it as a regular formula o_O
 
Upvote 0

Forum statistics

Threads
1,215,043
Messages
6,122,812
Members
449,095
Latest member
m_smith_solihull

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top