PDA

View Full Version : Passing Parameters Less Than Greater Than Or Equal To Not Equal To



PcMax
07-15-2012, 01:07 PM
Hi,

I have a loop that checks for a sample:



If strTempAry(ciclo, 5) <= V_AV Then


If strTempAry(ciclo, 5) >= V_AV Then

Wonder if you can pass as a parameter in vba: "<", "<=", ">", ">=", "=", "<>"

Thanks in advance

Excel Fox
07-15-2012, 03:14 PM
Try something like


Function CheckValues(varComp1 As Variant, varComp2 As Variant, strCheckString As String) As Boolean

CheckValues = Application.Evaluate(varComp1 & strCheckString & varComp2)

End Function

Sub Test()

MsgBox CheckValues(strTempAry(ciclo, 5), V_AV, "<=")

End Sub

PcMax
07-15-2012, 04:05 PM
Hi,

Thanks for the suggestion, I did not know you could do it that way.
I was already thinking about how many lines of code I had applications for such a comparison when the policy is in a spreadsheet cell

If strTempAry(ciclo, 5) <= V_AV And strTempAry(ciclo, 6) >= V_AV Then