I have a bunch of rows and 25 columns in a worksheet, and need to find the value in the 4th column based on columns B and C using VBA. I am using a combination of index and mult
May be a bit quicker using memory arrays:
Sub VariablesInArrayFormula()
Dim SA As String
SA = "Apples"
Dim C1 As String
C1 = "Oranges"
With Worksheets("Sheet1") 'Change to your worksheet
Dim DtaArray As Variant
DtaArray = .Range("B2:D27").Value
Dim i As Long
For i = LBound(DtaArray, 1) To UBound(DtaArray, 1)
Dim ans
If DtaArray(i, 1) = SA And dtaaray(i, 2) = C1 Then
ans = DtaArray(i, 3)
Exit For
End If
Next i
.Range("G1").Value = ans
End With
End Sub