I have a row of cells that each do a wildcard search on a text string to deliver a 1 result if true. the formula is as follows;
=IF(ISNUMBER(SEARCH("*A40",B52)), 1, "")
The problem I have is that 2 other cell formulas clash which are;
=IF(ISNUMBER(SEARCH("*A408",B52)), 1, "")
=IF(ISNUMBER(SEARCH("*A4087",B52)), 1, "")
All formulas when finding A4087 return a 1 when I only want it in the last
The first 2 formulas return a 1 when finding A408 and I only want it in the second.
I have tried using a space i.e. "*A40 " & "*A408 " but then I lose data if words run into the string i.e. A40silver would not pick up the text at all.
My proposed solution is to do a conditional if statement i.e. for the A40 search, if A40 is found check if there is a "" in the other 2 corresponding cells before returning a 1. But I can't get the if statement to work. I am sure it should be possible and fairly straight forward but am really struggling to find the written solution !!!![]()
Are there any takers to help me out please. I can happily mock up something to explain better if required. Oh...and I want to stick with formula and not use VBA on this.
regards
Simon
Last edited by opsman; 02-03-2010 at 10:28 PM. Reason: Added attachment
Can you fathom/describe a logic we can then explain to a formula or a macro that says:
A40silver IS an in-string match to A40
A4087red is top of the range is NOT and in-string match to A40 (which clearly is a match unless we add something)
Pretty much anything I can think of would match both strings.
_________________
Microsoft MVP 2010 - Excel
Visit: Jerry Beaucaire's Excel Files & Macros
If you've been given good help, use theicon below to give reputation feedback, it is appreciated.
Always put your code between code tags. [CODE] your code here [/CODE]
“None of us is as good as all of us” - Ray Kroc
“Actually, I *am* a rocket scientist.” - JB (little ones count!)
I was thinking that (using the book 1 as an example) I could write something in B5 (and then drag) like;
IF(C5:D5<>1, THEN IF(ISNUMBER(SEARCH("*A40",A5)), 1, ""))
It obviously doesn't make sense within excel but does that give an expert an idea of where I'm coming from or going wrong?
Apologies - I think you require an answer from me - the search is purely for A40, A408, A4087 but as seperate and unrelated items.
Last edited by opsman; 02-03-2010 at 07:23 PM. Reason: correction
Can you describe a logic that results in A4087 not matching when a search for A40 is conducted. I can't.
SEARCH() would match both.
FIND() would match both.
In VBA, .FIND() would match both...
Unless you can describe a method the causes A40 to NOT match against A4087, I'm not sure how to do it, either.
_________________
Microsoft MVP 2010 - Excel
Visit: Jerry Beaucaire's Excel Files & Macros
If you've been given good help, use theicon below to give reputation feedback, it is appreciated.
Always put your code between code tags. [CODE] your code here [/CODE]
“None of us is as good as all of us” - Ray Kroc
“Actually, I *am* a rocket scientist.” - JB (little ones count!)
Guys....lol...
These major NOT hints you are sending me....lol....
Are you saying that if I put something for A40 & A408 formula i.e. the conflicting ones...?
Excuse me for being a little dumb...
Searching for A40 and stipulating NOT A408 OR A4087 would be cool.
Searching for A408 and stipulating NOT A4087 would also do the trick....
Can you work with that? It's making sense to me now although how to ammend the formula isn't![]()
=LOOKUP(10, SEARCH({"A40","A408","A4087"}, A1))
... will return #N/A, 1, 2, or 3
Microsoft MVP - Excel
Entia non sunt multiplicanda sine necessitate
I've applied it to the example but only get a return of N/A and 1... and in the wrong places
I guess it was worth a try.... I just can't understand it seems so simple in my mind, 3 seperate formulas in 3 seperate cells unrelated but checking the same text string....
1. Find A40 in the string but if A40 turns out to be A408 or A4087 then ignore it
2. Find A408 in the string but if turns out to be A4087 then ignore it
3. Find A4087 in the string
You guys always come up trumps and I'm thinking maybe I didn't explain it correctly or something...
The 3 formulas belong in seperate cells does that make a difference (i.e. I just want a return of 1 in each individual cell if the parameters are met, not a 1,2,3)
Guys
Solved it, well it works on the example I provided which I've attached in case it's of use to others....It must have been the 02.00am coffee that did it! lol... I'm soooo happy as I must be learning at last and now I can go get some sleep!!
To get A40 only as a 1 return;
=IF(ISNUMBER(SEARCH("*A4087",A5)),"",IF(ISNUMBER(SEARCH("*A408",A5)),"",IF(ISNUMBER(SEARCH("*A40",A5 )),1,"")))
To get A408 only as a 1 return;
=IF(ISNUMBER(SEARCH("*A4087",A5)),"",IF(ISNUMBER(SEARCH("*A408",A5)),1,IF(ISNUMBER(SEARCH("*A40",A5) ),"","")))
To get A4087 only as a 1 return;
=IF(ISNUMBER(SEARCH("*A4087",A5)),1,IF(ISNUMBER(SEARCH("*A408",A5)),"",IF(ISNUMBER(SEARCH("*A40",A5) ),"","")))
It may be simple but I'm so happy that I worked it out myself !! Back soon no doubt....
Thanks to all.
Try this:
=IF(SUMPRODUCT(COUNTIF($A5,"*"&$B$4:$E$4&"*"))=COLUMNS($B:B),1,"")
copy across and down
I'm glad you got a formula that works for you, and checking individually for the values you want to SKIP if matched is a good idea.
I didn't suggest that originally because your sample sheet indicated "and so on, and so on" in the titles...which made me think the value to be added would be more and more variations on the same codes...
This technique is not supportable ad infinitum. But in small groups like this, very manageable!
Here, you can actually reduce the formulas to this, I think:
To get A40 only as a 1 return;
=IF(ISNUMBER(SEARCH("*A4087",A5)),"",IF(ISNUMBER(SEARCH("*A408",A5)),"",IF(ISNUMBER(SEARCH("*A40",A5 )),1,"")))
To get A408 only as a 1 return;
=IF(ISNUMBER(SEARCH("*A4087",A5)),"",IF(ISNUMBER(SEARCH("*A408",A5)),1,""))
To get A4087 only as a 1 return;
=IF(ISNUMBER(SEARCH("*A4087",A5)),1,"")
As the length of the code to find lengthens, the need to "eliminate" the shorter versions disappears. You need to eliminate the longer codes when matching a short one.![]()
_________________
Microsoft MVP 2010 - Excel
Visit: Jerry Beaucaire's Excel Files & Macros
If you've been given good help, use theicon below to give reputation feedback, it is appreciated.
Always put your code between code tags. [CODE] your code here [/CODE]
“None of us is as good as all of us” - Ray Kroc
“Actually, I *am* a rocket scientist.” - JB (little ones count!)
I did think afterwards about the shortening of codes and it actually may become necessary when things expand. I did find when doing other searches that there were odd anomolies that sprung up i.e. Searching for NB getting counted when the word rainbow was in the string and this did quickly fill up the ammount of nested ifs I could use.
Whilst I have successfully completed what I set out to achieve I think I may need to look at VB in order to expand the spreadsheet. But the buzz of sorting it myself still remains and having achieved it I didn't sleep a wink all night, it was a real Eureka moment for me....
I do need to say thank you to everybody here as the forum has really helped me progress in gaining knowledge and started me thinking in a different way of how to solve different problems.
Cheers to all and have a good weekend!
There are currently 1 users browsing this thread. (0 members and 1 guests)
Bookmarks