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
 

Excel Facts

How to calculate loan payments in Excel?
Use the PMT function: =PMT(5%/12,60,-25000) is for a $25,000 loan, 5% annual interest, 60 month loan.
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
 
Upvote 0

Forum statistics

Threads
1,214,813
Messages
6,121,706
Members
449,048
Latest member
81jamesacct

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
Back
Top