generating a formula using a text string as a math operator (expression)

jey_sea

New Member
Joined
Apr 23, 2010
Messages
24
Hi, need help with generating a formula. I'm grabbing a text string from a cell that may contain any one of the four following:
<,>, <=,>=.

Question; how can I generate a formula with the string as an math operator?

example:

Operator = cell(1,1) ' note cell contains "<="
If X Operator Y Then .....
note the expression (in red) should be If X <= Y Then ......

I'm sure someone out there has done this before>.

Thanks
 

Excel Facts

How to calculate loan payments in Excel?
Use the PMT function: =PMT(5%/12,60,-25000) is for a $25,000 loan, 5% annual interest, 60 month loan.
This isn't very clear. I understand where the operator comes from. What goes to the left and right of it?
 
Upvote 0
Hi, sorry for more being more clear!

If X is less then or equal to Y then
cell(2,1)="Pass"
else
cell(2,1)="Fail"
end if


the less then or equal to is the string from Cell(1,1) ; ie "<="
 
Upvote 0
Maybe like this

Code:
If Evaluate(Cells(5, 1).Value & Cells(1, 1) & Cells(2, 1).Value) Then
    Cells(2, 1) = "Pass"
Else
    Cells(2, 1) = "Fail"
End If
 
Upvote 0
Hi, sorry for more being more clear!

If X is less then or equal to Y then
cell(2,1)="Pass"
else
cell(2,1)="Fail"
end if


the less then or equal to is the string from Cell(1,1) ; ie "<="
 
Upvote 0

Forum statistics

Threads
1,224,521
Messages
6,179,285
Members
452,902
Latest member
Knuddeluff

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top