# Include "OR" condition in Instr command

#### mtheriault2000

##### Well-known Member
Hello

A line in my worksheet as individual data in each cells like
"A4 B4 C4 D4 E4 F4 G4 H4"
"EURUSD" "Stop" "If" "Bid" "Buy" "35" "000" "1.4523"

I want to rebuilt the string that is separated by individual cells

To do so, i want to loop until string variable TS as cell value = "Sell" Or "Buy".

Read the value of a sell, built a string.
Code:
``````       While [B][U][I][COLOR=red]InStr(1, TS, ( "Sell" Or "Buy") = 0[/COLOR][/I][/U][/B]
TS = RANGE("a1").Offset(r, CC).Value
CT = CT & Space(1) & TS
CC = CC + 1
Wend``````

My Instr command line is erroneous and gave me an incompatibility error.

Hope i'm clear enough

Martin

### Excel Facts

Why are there 1,048,576 rows in Excel?
The Excel team increased the size of the grid in 2007. There are 2^20 rows and 2^14 columns for a total of 17 billion cells.

#### jbeaucaire

##### Well-known Member
List each separately:
Code:
``While InStr(1, TS, "Sell") = 0 And InStr(1, TS, "Buy") = 0``

#### mtheriault2000

##### Well-known Member
Thank you

I did test them separatly to resolve my problem, but i prefer your solution

Code:
``````Do
TS = RANGE("a1").Offset(r, CC).Value
[COLOR=red] If InStr(1, TS, "Buy") > 0 Then Exit Do
If InStr(1, TS, "Sell") > 0 Then Exit Do
[/COLOR]         RT = RT & Space(1) & TS
CC = CC + 1
Loop
RANGE("a1").Offset(r, c).Value = Trim(RT)``````

Martin

Replies
5
Views
752
Replies
17
Views
590
Replies
23
Views
294
Replies
1
Views
355
Replies
3
Views
165

1,127,601
Messages
5,625,749
Members
416,133
Latest member
ToseSenpai

### We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.

### Which adblocker are you using?

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

### Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

### Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back