![]() |
![]() |
|
|||||||
| Excel Questions All Excel/VBA questions - formulas, macros, pivot tables, general help, etc. Please post to this forum in English only. |
![]() |
|
|
Thread Tools | Display Modes |
|
|
#1 |
|
Board Regular
Join Date: May 2002
Posts: 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. |
|
|
|
|
|
#2 | |
|
MrExcel MVP
Join Date: Feb 2002
Location: The Hague
Posts: 50,317
|
Quote:
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 ] |
|
|
|
|
|
|
#3 |
|
Board Regular
Join Date: May 2002
Posts: 91
|
thanks aladin. can you help me with vb script for the same
|
|
|
|
|
|
#4 |
|
Board Regular
Join Date: May 2002
Posts: 91
|
Aladin, Its not working
|
|
|
|
|
|
#5 | |
|
MrExcel MVP
Join Date: Feb 2002
Location: The Hague
Posts: 50,317
|
Quote:
|
|
|
|
|
|
|
#6 | |
|
MrExcel MVP
Join Date: Feb 2002
Location: The Hague
Posts: 50,317
|
Quote:
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 ] |
|
|
|
|
|
|
#7 |
|
Board Regular
Join Date: May 2002
Posts: 91
|
Aladin, is there a simple way. as i have to search for 20 different values in on cell
thanks |
|
|
|
|
|
#8 | |
|
MrExcel MVP
Join Date: Feb 2002
Location: The Hague
Posts: 50,317
|
Quote:
=(SUMPRODUCT((ISNUMBER(SEARCH($E$1:$E$20,A1)))+0)>0)+0 where E1:E20 houses the substrings of interest. Aladin |
|
|
|
|
![]() |
| Bookmarks |
| Thread Tools | |
| Display Modes | |
|
|