How to search multiple partial values

jkpd2000

Board Regular
Joined
May 8, 2002
Messages
91
Hi,
I want to write a code to find a multiple partial values in a string and place 1 or 0 in the beside cell.

ex. a1 = "ABCDEFG"
a2 = "HGIJKLM"
a3 = "ABCDEFG"

i want to search for "CDE" or "EFG"
and place 1 or 0 in the beside cell.

the result should be

b1 1
b2 0
b3 1

i want it programatically so that i can automate. Please tell the instructions also of how to do it from beginning to end from making the code and puuting it and running it, as i am new to excel.

thanks in advance.
 

Excel Facts

How can you turn a range sideways?
Copy the range. Select a blank cell. Right-click, Paste Special, then choose Transpose.
On 2002-05-09 09:03, jkpd2000 wrote:
Hi,
I want to write a code to find a multiple partial values in a string and place 1 or 0 in the beside cell.

ex. a1 = "ABCDEFG"
a2 = "HGIJKLM"
a3 = "ABCDEFG"

i want to search for "CDE" or "EFG"
and place 1 or 0 in the beside cell.

the result should be

b1 1
b2 0
b3 1

i want it programatically so that i can automate. Please tell the instructions also of how to do it from beginning to end from making the code and puuting it and running it, as i am new to excel.

thanks in advance.

If you're not looking for code in VBA perse,

in B1 enter and copy down:

=ISNUMBER(SEARCH($E$1,A1))+0

where E1 houses a target substring to look for.

If you want to look for 2 substrings at a time,

In B1 enter and copy down:

=(ISNUMBER(SEARCH($E$1,A1))+ISNUMBER(SEARCH($E$2,A1))>0)+0

will look for substrings in E1 and E2 in one go.

Addendum: If you'd like it case-sensitive, use FIND instead of SEARCH in the foregoing formulas.

Postscript. Edited for locking E1 & E2 and the longer formula for extraneous paren and wrong ref.

Aladin
This message was edited by Aladin Akyurek on 2002-05-09 09:13
This message was edited by Aladin Akyurek on 2002-05-09 09:14
This message was edited by Aladin Akyurek on 2002-05-09 09:31
 
Upvote 0
On 2002-05-09 09:22, jkpd2000 wrote:
Aladin, Its not working

I forgat to tell to freeze E1 and E2.
Simply change them to $E$1 and $E$2.
See the original reply I edited for that mistake and other omissions.

Cheers.

Aladin
This message was edited by Aladin Akyurek on 2002-05-09 09:33
 
Upvote 0
Aladin, is there a simple way. as i have to search for 20 different values in on cell

thanks
 
Upvote 0
On 2002-05-09 09:49, jkpd2000 wrote:
Aladin, is there a simple way. as i have to search for 20 different values in on cell

thanks

Yes.

=(SUMPRODUCT((ISNUMBER(SEARCH($E$1:$E$20,A1)))+0)>0)+0

where E1:E20 houses the substrings of interest.

Aladin
 
Upvote 0

Forum statistics

Threads
1,213,487
Messages
6,113,937
Members
448,534
Latest member
benefuexx

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