ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Code for variable criteria (https://www.excelbanter.com/excel-programming/298872-code-variable-criteria.html)

Otto Moehrbach[_6_]

Code for variable criteria
 
Excel 2002, WinXP
The macro below demonstrates what I need but my actual situation is this:
I search a column of 100+ strings for any one of 6 strings.
I find one of the 6 strings.
Using a Select Case construct I define a numerical criteria with which to
test the cell to the right of the found cell. The Select Case construct is
based on which of the 6 strings was found.
This numerical criteria is in the form of a string, i.e., "=10" or "=0" or
"<=0" or similar.
My question is: How do I apply that string criteria to test the cell
content?
I can easily change virtually anything in how I am doing this. Thanks for
your help. Otto

Sub Test()
Dim i As Range
Dim Crit As String
Set i = [A1] 'Found cell
Crit = "=10" 'From the Select Case
If i.Offset(, 1) ?????? Then
MsgBox "Yes"
Else
MsgBox "No"
End If
End Sub



No Name

Code for variable criteria
 
Try using the IsNumeric function in VBA.


-----Original Message-----
Excel 2002, WinXP
The macro below demonstrates what I need but my actual

situation is this:
I search a column of 100+ strings for any one of 6

strings.
I find one of the 6 strings.
Using a Select Case construct I define a numerical

criteria with which to
test the cell to the right of the found cell. The Select

Case construct is
based on which of the 6 strings was found.
This numerical criteria is in the form of a string,

i.e., "=10" or "=0" or
"<=0" or similar.
My question is: How do I apply that string criteria to

test the cell
content?
I can easily change virtually anything in how I am doing

this. Thanks for
your help. Otto

Sub Test()
Dim i As Range
Dim Crit As String
Set i = [A1] 'Found cell
Crit = "=10" 'From the Select Case
If i.Offset(, 1) ?????? Then
MsgBox "Yes"
Else
MsgBox "No"
End If
End Sub


.



All times are GMT +1. The time now is 12:27 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com