P
Post Tenebras Lux
I would like to build a variable IF statement, that is being run in VBA code,
that draws the operand (>, < , = , >=, <=) from a cell on the spreadsheet.
The purpose is to permit the user to test a variety of conditions (which the
rest of the code does). Sort of like allowing the user to build an SQL query
on the fly.
For example:
I want to replace the following code:
If Signal > 0 and Signal < 100 then
'do something
End if
with something like this:
Dim strOperand1 as string, strOperand2 as string
If Signal strOperand1 0 and Signal strOperand2 100 then
' do something
End if
strOperand1 and strOperand2 would contain, for example, ">" and "<",
respectively. Each of these values would be entered by the spreadsheet user
into a cell directly (which is range named - so that strOperand1 =
Range("Operand1").value - for example).
I've tried & Evaluate(Operand1) & , but that doesn't work.
Any suggestions would be greatly appreciated!
that draws the operand (>, < , = , >=, <=) from a cell on the spreadsheet.
The purpose is to permit the user to test a variety of conditions (which the
rest of the code does). Sort of like allowing the user to build an SQL query
on the fly.
For example:
I want to replace the following code:
If Signal > 0 and Signal < 100 then
'do something
End if
with something like this:
Dim strOperand1 as string, strOperand2 as string
If Signal strOperand1 0 and Signal strOperand2 100 then
' do something
End if
strOperand1 and strOperand2 would contain, for example, ">" and "<",
respectively. Each of these values would be entered by the spreadsheet user
into a cell directly (which is range named - so that strOperand1 =
Range("Operand1").value - for example).
I've tried & Evaluate(Operand1) & , but that doesn't work.
Any suggestions would be greatly appreciated!