Given what you requested, I think your easier solution would be to still let Excel do the heavy lifting, but not keep it as Excel formulas once you're done (ie convert it to values).
That being the case, this should do it:
Sub PutInFormulas()
ActiveSheet.Range("A2").Formula = "=IFERROR(IF(MATCH(OFFSET(Sheet1!$G$2;COLUMN();0);Sheet2!$K3:$AE3;0);1;0);0)"
ActiveSheet.Range("A2").Copy ActiveSheet.Range("A2:AD20000")
ActiveSheet.Range("A2:AD20000").Value = ActiveSheet.Range("A2:AD20000").Value
End Sub
Basically, your first step is to make it a formula you can paste down and across, so you replace your Sheet1!G3
with an Offset()
reference that increments one row for each column you move across (In other words, any formula in Column A will reference G3
, column B will reference G4
, etc.) and to put that formula in cell A2
Next you copy it across to your entire range
Finally your convert the formulas to values.
Hope this makes sense / does the trick!!