ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Discussion (Misc queries) (https://www.excelbanter.com/excel-discussion-misc-queries/)
-   -   comlex Find statement (https://www.excelbanter.com/excel-discussion-misc-queries/230431-comlex-find-statement.html)

Farooq Sheri

comlex Find statement
 
Is it possible to write a single Find statement in code that will search for
a first string in say Range("A2") and if true look for another string in
Range("B2").

Jacob Skaria

comlex Find statement
 
Use LEFT,MID,RIGHT functions

A2 = apple
B2 = boy

=IF(LEFT(A2,1)="a",LEFT(B2,1),"")
--
If this post helps click Yes
---------------
Jacob Skaria


"Farooq Sheri" wrote:

Is it possible to write a single Find statement in code that will search for
a first string in say Range("A2") and if true look for another string in
Range("B2").


Rick Rothstein

comlex Find statement
 
Why do you think it is important for it to be a single statement? Aside from
that, it would have been nice if you gave some examples so we would know if
you are trying to find whole or partial matches. With that said, I don't
think you need to use the Find function at all. If you are looking for whole
matches, then just test the cells content directly...

If Range("A2").Value = "Text1" And Range("B2").Value = "Text2" Then

If, on the other hand, you are looking for partial matches, then use the
InStr function...

If InStr(Range("A2").Value, "Text1") 0 And _
InStr(Range("B2").Value, "Text2") 0 Then


--
Rick (MVP - Excel)


"Farooq Sheri" wrote in message
...
Is it possible to write a single Find statement in code that will search
for
a first string in say Range("A2") and if true look for another string in
Range("B2").




All times are GMT +1. The time now is 08:56 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com