I'm not sure if VBA for Excel has this or not, but I'm trying to find a way to find a given value regardless if the filter is on or off. I’m trying to make the code below run faster and hoping that find will be faster then the do…loop code I have below (MAX_AREA_ROWS is in my globals module):
Code:
Function ModFTQ(qty, X, Y, Z)
Application.Volatile
X= X& Y
Application.Volatile
With CEIDData
If .FilterMode = False Then
Set j = .Cells.Find(X, LookIn:=xlValues)
j = j.Row
Else:
j = 1
[b]Do While .Cells(j, Z.Column).Value <> X And j < MAX_AREA_ROWS
j = j + 1
Loop[/b]
End If
If qty < .Cells(j, 4).Value Then
ModFTQ = .Cells(j, 4).Value
ElseIf qty > .Cells(j, 5).Value And .Cells(j, 5).Value <> "-1" Then
ModFTQ = .Cells(j, 5).Value
Else: ModFTQ = qty
End If
End With
End Function