![]() |
![]() |
|
|||||||
| 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: Feb 2002
Location: South UK
Posts: 344
|
Hi All Does anyone know how I may do this.
I need to be able to search a field that will contain a text value. I want to use the IF statement "If A1 contains "4" then do this" The field may contain several references seperated ie "2;3;4;5;6;7" or "1;4;7" Any help would be appreciated Kevin [ This Message was edited by: swaink on 2002-04-04 08:15 ] |
|
|
|
|
|
#2 |
|
MrExcel MVP
Join Date: Feb 2002
Location: Austin, Texas USA
Posts: 11,654
|
=IF(ISNUMBER(SEARCH("*4*",A1)),"do this","do that")
|
|
|
|
|
|
#3 | |
|
MrExcel MVP
Join Date: Feb 2002
Location: Newcastle, UK
Posts: 1,174
|
Quote:
The field may contain several references seperated ie "2;3;4;5;6;7" which field? A1 etc. or the IF() criteria?
__________________
"Have a good time......all the time" Ian Mac |
|
|
|
|
|
|
#4 | |
|
MrExcel MVP
Join Date: Mar 2002
Location: Michigan USA
Posts: 11,452
|
Quote:
This should get you started ... then you can enhance it to do some further error checking: in cell C5 2;3;4;5 =IF(FIND("4",C5,1),"Found It","no 4 here") with the result Found It Please post back if it works for you ... otherwise explain a little further and let us take it from there
__________________
Regards! Yogi Anand, D.Eng, P.E. Energy Efficient Building Network LLC www.energyefficientbuild.com |
|
|
|
|
|
|
#5 |
|
Board Regular
Join Date: Feb 2002
Location: South UK
Posts: 344
|
Mark, Ian
Many thanks for your response. Mark that works a treat. And Ian It was the field that may contain the text value, sorry if i confused you. Thanks again Kevin |
|
|
|
|
|
#6 | |
|
MrExcel MVP
Join Date: Mar 2002
Location: Michigan USA
Posts: 11,452
|
Quote:
That's neat ... looks better than mine with the find and act approach. One question, why the leading a nd trailing * -- your formula does work without the * also. TIA |
|
|
|
|
|
|
#7 | |
|
MrExcel MVP
Join Date: Feb 2002
Location: Austin, Texas USA
Posts: 11,654
|
Quote:
=SUM(ISNUMBER(SEARCH("*4*",A1)),0,1,1) Also it's easy to change into an AND condition... =IF(ISNUMBER(SEARCH("*4*7*",A1)),"do this","do that") ...returns "do this" if an ordered list (implemented as a text string) contains both 4 and 7. [ This Message was edited by: Mark W. on 2002-04-04 09:22 ] |
|
|
|
|
|
|
#8 |
|
MrExcel MVP
Join Date: Mar 2002
Location: Michigan USA
Posts: 11,452
|
Thanks Mark!
I did expect to hear some thing along this line. [ This Message was edited by: Yogi Anand on 2002-04-04 09:25 ] |
|
|
|
|
|
#9 | ||
|
MrExcel MVP
Join Date: Feb 2002
Location: Newcastle, UK
Posts: 1,174
|
Quote:
__________________
"Have a good time......all the time" Ian Mac |
||
|
|
|
![]() |
| Bookmarks |
| Thread Tools | |
| Display Modes | |
|
|