Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Junior Member
 
Posts: 13
Default Inserting variable into code

Hi and thanks in advance.

I have some code where I would like to insert a string variable that 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
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 587
Default Inserting variable into code

hi deutz,

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

--
isabelle



Le 2012-05-31 21:26, deutz a écrit :
Hi and thanks in advance.

I have some code where I would like to insert a string variable that
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


--------------------




  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 31
Default Inserting variable into code

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





On May 31, 9:26*pm, deutz wrote:
Hi and thanks in advance.

I have some code where I would like to insert a string variable that
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

--------------------

--
deutz


Reply
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
Inserting variable outputs into different ranges Genix Excel Programming 2 August 16th 09 06:26 PM
Using variable name as a value for inserting a row T8RSP[_2_] Excel Programming 3 November 7th 05 09:14 AM
Inserting Variable Number of Rows bundyloco[_7_] Excel Programming 2 August 29th 05 11:25 AM
inserting a variable into VB edb Excel Programming 2 February 29th 04 12:39 PM


All times are GMT +1. The time now is 05:35 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"