Inserting variable into code

D

deutz

Hi and thanks in advance.

I have some code where I would like to insert a string variable tha
holds an operator which will be either = or <>

The InStr line in the code below results in a Type Mismatch error ...


Code
-------------------

If some condition then
strOperator = "<>"
Else
strOperator = "="
End If

If InStr(1, rng.Value, "ZAC") & strOperator & 0 Then
 
I

isabelle

hi deutz,

x = InStr(1, rng.Value, "ZAC")
If Evaluate(x & strOperator & 0) Then

--
isabelle



Le 2012-05-31 21:26, deutz a écrit :
 
B

Bob Flanagan

Try this instead:

bFound = instr(1, rng.value, "ZAC") >0
if strOperator ="<>" and not bFound then

elseif strOperator ="=" and bfound then

end if

Robert Flanagan
Add-ins.com LLC
http://www.add-ins.com
Productivity add-ins and downloadable books on VB macros for Excel
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top