LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 41
Default Variable IF statement (in VBA)

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!


 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Variable statement doobie Excel Discussion (Misc queries) 3 November 11th 09 07:42 AM
Variable in if statement Francis Hookham Excel Worksheet Functions 9 December 12th 07 02:35 PM
IF Statement Variable Jase4now Excel Discussion (Misc queries) 3 September 25th 07 10:48 PM
if than statement has too many variable repke New Users to Excel 1 May 2nd 06 02:00 PM
Macro Creating Variable and using variable in a SQL statement Jimmy Excel Programming 4 October 25th 04 02:36 AM


All times are GMT +1. The time now is 08:54 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"