Hi everyone,
I have a set of numbers that must be analized with the comparison operators. It would be really efficient if I could pass these operators as paramaters.
I tried to solve this with the Evaluate function and it works when I compare whole numbers but when I switch to decimal numbers it gives me the type mismatch error.
Can someone please explain why this code doesn't work for decimal numbers?
Here is a data sample that the code must run on.
[TABLE="width: 128"]
<colgroup><col width="64" span="2" style="width:48pt"> </colgroup><tbody>[TR]
[TD="width: 64, align: right"]1[/TD]
[TD="width: 64, align: right"]2[/TD]
[/TR]
[TR]
[TD="align: right"]2[/TD]
[TD="align: right"]3[/TD]
[/TR]
[TR]
[TD="align: right"]0,127[/TD]
[TD="align: right"]0,0841[/TD]
[/TR]
[TR]
[TD="align: right"]0,108[/TD]
[TD="align: right"]0,0812[/TD]
[/TR]
</tbody>[/TABLE]
I have a set of numbers that must be analized with the comparison operators. It would be really efficient if I could pass these operators as paramaters.
I tried to solve this with the Evaluate function and it works when I compare whole numbers but when I switch to decimal numbers it gives me the type mismatch error.
Can someone please explain why this code doesn't work for decimal numbers?
Code:
Sub test(op1 As String)
Dim c As Range
For Each c In ActiveSheet.Range("A1:A10")
If Evaluate(c.Value & op1 & c.Offset(0, 1)) Then MsgBox "It works"
Next c
End Sub
Sub caller()
test "<"
End Sub
Here is a data sample that the code must run on.
[TABLE="width: 128"]
<colgroup><col width="64" span="2" style="width:48pt"> </colgroup><tbody>[TR]
[TD="width: 64, align: right"]1[/TD]
[TD="width: 64, align: right"]2[/TD]
[/TR]
[TR]
[TD="align: right"]2[/TD]
[TD="align: right"]3[/TD]
[/TR]
[TR]
[TD="align: right"]0,127[/TD]
[TD="align: right"]0,0841[/TD]
[/TR]
[TR]
[TD="align: right"]0,108[/TD]
[TD="align: right"]0,0812[/TD]
[/TR]
</tbody>[/TABLE]