I'm trying to search for a result based on 2 criteria. "For Each" is much too slow.
This code is much faster. It writes a formula in the cell and then converts it to text. After a few hundred lines, values are still in the cell but they are no longer correct.
I tried manually pasting the =LOOKUP
formula. It fetches the correct value, so I assume that it's moving so fast it doesn't have time to find the correct value before it's converted to text.
Sheets("Combined").Select
'put the formula in the first cell
Sheets("Combined").Range(ColumnLetter & "2").Value = "=LOOKUP(2,1/('SheetName'!B:B=Combined!B2)/('SheetName'!A:A=Combined!A2),'SheetName'!C:C)"
'copy the formula all the way down
Sheets("Combined").Range(ColumnLetter & "2").AutoFill Destination:=Range(ColumnLetter & "2:" & ColumnLetter & lastRow)
'convert the result to text
Sheets("Combined").Range(ColumnLetter & "2:" & ColumnLetter & lastRow).Value = Sheets("Combined").Range(ColumnLetter & "2:" & ColumnLetter & lastRow).Value