SEARCH looks for an item in a target string. If it locates the item, it reports at which position the item occurs with the target string. Hence those numbers, otherwise we get #VALUE!. COUNT that we used around SEARCH yields a 1 for a number, 0 for #VALUE!. Since a non-zero number means TRUE, we get "erase", otherwise "" with:
=IF(COUNT(SEARCH($E$1&" ",A1&" ")),"erase","")
Try...
=IF(COUNT(SEARCH("-"&$E$1&" ","-"&A1&" ")),"erase","")
A1-earth | | | |
A2-earthquake | | | |
A3-earthworm | | | |
A4-pearlearth | | erase | |
A5-goodearth | | erase | |
<tbody>
[TD="align: right"]1[/TD]
[TD="width: 64"][/TD]
[TD="width: 64"]erase[/TD]
[TD="width: 64"]earth[/TD]
[TD="align: right"]1[/TD]
[TD="align: right"]1[/TD]
[TD="align: right"]6[/TD]
[TD="align: right"]5[/TD]
</tbody>
i have data in A1:A5
I wanted to find out rows with the word "earth" on it. that means the result should be row1 only.
WHEN i applied -search("earth",A1) i got the digits as answers.in col B
when i applied your formula-=IF(COUNT(SEARCH($E$1&" ",A1&" ")),"erase","") i got unexpected results.in col C .kindly see it and comment please.
=IF(COUNT(SEARCH($E$1&" ",A1&" ")),"erase","")
=IF(COUNT(SEARCH("-"&$E$1&" ","-"&A1&" ")),"erase","")
i compared the two formulas and found that the difference is the presence of a dash. what does this character tell excel? I am little bit confused about it. since i don't have a dash before the word "earth". but the formula worked right when it was added!
i would also like to know why does the digits appeared as a result of the first formula in col B? thanks
=======================
aldin said
1)SEARCH looks for an item in a target string. If it locates the item, it reports at which position the item occurs with the target string. Hence those numbers, otherwise we get #VALUE!. COUNT that we used around SEARCH yields a 1 for a number, 0 for #VALUE!. Since a non-zero number means TRUE, we get "erase", otherwise "" with:
2)A1-earth 1 erase earth
A2-earthquake 1
A3-earthworm 1
A4-pearlearth 6 erase
A5-goodearth 5 erase
i have data in A1:A5
I wanted to find out rows with the word "earth " on it. that means the result should be row1 only.
3)aldin said>SEARCH looks for an item in a target string. If it locates the item, it reports at which position the item occurs with the target string.
here target string is in A1:A5.we are searching for "earth"&""
it is available only in A1 and the position is 1 right?
My doubt is , if it is so, then why the digits in A2:A5,where there is no word we are searching for?
You said> otherwise we get #VALUE!.
even then we got digits for A2:A5.?