Include "OR" condition in Instr command

mtheriault2000

Well-known Member
Joined
Oct 23, 2008
Messages
826
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
 

Some videos you may like

Excel Facts

Round to nearest half hour?
Use =MROUND(A2,"0:30") to round to nearest half hour. Use =CEILING(A2,"0:30") to round to next half hour.

jbeaucaire

Well-known Member
Joined
May 8, 2002
Messages
6,012
List each separately:
Code:
While InStr(1, TS, "Sell") = 0 And InStr(1, TS, "Buy") = 0
 

mtheriault2000

Well-known Member
Joined
Oct 23, 2008
Messages
826
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
 

Watch MrExcel Video

Forum statistics

Threads
1,122,381
Messages
5,595,843
Members
414,025
Latest member
haraop

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.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

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

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

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
Top