![]() |
|
|
|||||||
| Lounge v.2.0 A place to chat. |
![]() |
|
|
Thread Tools | Display Modes |
|
|
|
|
#1 | |
|
Join Date: Oct 2006
Location: Bryan, TX
Posts: 14,397
|
Quote:
In that case, here's an update to my UDF to account for that... Code:
Public Function Jonmo1(C As Range, L As Range)
Dim MyArray As Variant
Dim X As Long, Y
Dim MyString As String
MyArray = Split(C, " ")
Jonmo1 = ""
For X = LBound(MyArray) To UBound(MyArray)
MyString = Replace(MyArray(X), Chr(160), "")
Y = Application.Match(MyString, L.Columns(1), 0)
If Not IsError(Y) Then
Jonmo1 = L(Y, 2)
Exit For
End If
Next X
End Function
__________________
The more we learn, and the better we get at our trade, the easier it becomes to overlook the obvious. |
|
|
|
|
|
|
#2 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
MrExcel MVP
Join Date: Feb 2002
Location: The Hague
Posts: 39,500
|
Quote:
=LOOKUP(9.99999999999999E+307,SEARCH(" "&$D$2:$D$10&" "," "&A2&" "),$E$2:$E$10) should simply work. |
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
|
|
|
#3 |
|
Join Date: Nov 2004
Location: UK
Posts: 1,743
|
Aladin - did you see my post - the downloaded file isn't quite what it looks like...
I think Code:
=IF(ISNA(LOOKUP(2^15,SEARCH(" "&$D$2:$D$10&" "," "&A2&" "),$E$2:$E$10)),LOOKUP(2^15,SEARCH(" "&$D$2:$D$10&CHAR(160)," "&A2&" "),$E$2:$E$10),LOOKUP(2^15,SEARCH(" "&$D$2:$D$10&" "," "&A2&" "),$E$2:$E$10))
__________________
Emma Your apparent nonchalance belies the fact that you can only think of me. Last edited by cornflakegirl; Jun 17th, 2008 at 06:11 PM. |
|
|
|
|
|
#4 |
|
Join Date: Apr 2007
Location: Cincinnati, Ohio
Posts: 5,337
|
Ok thanks for the explanation, I see that now.
__________________
Always make a back up copy before trying new code, you never know what you might lose! |
|
|
|
|
|
#5 | |
|
MrExcel MVP
Join Date: Feb 2002
Location: The Hague
Posts: 39,500
|
Quote:
If it's the case that A2 has a bunch of CHAR(160), it is simpler to invoke: Code:
=LOOKUP(9.99999999999999E+307,
SEARCH(" "&$D$2:$D$10&" "," "&SUBSTITUTE(A2,CHAR(160),"")&" "),
$E$2:$E$10)
|
|
|
|
|
|
|
#6 | |
|
Join Date: Apr 2007
Location: Calgary, Alberta
Posts: 317
|
Aladin,
I am running XL2003 and have no issue with the first posted formula. It works perfectly. M Quote:
__________________
"Wisdom is the right use of knowledge. To know is not to be wise. Many men know a great deal, and are all the greater fools for it. There is no fool so great a fool as a knowing fool. But to know how to use knowledge is to have wisdom." C. Spurgeon - (1834 - 1892) system: WinXP - Excel2003 |
|
|
|
|
|
|
#7 |
|
Join Date: Jun 2008
Posts: 0
|
Hi everyone,
Was happy to see my question posted as the challenge. I'm a new user to this forum and appreciate all the responses. Richard, have tried your solution and it solves most of the issue. However, i noticed a few limitations still exist; 1. If no keyword match is found the first result is still returned. Anyway to have a blank returned if no match found? 2. If a new row is added to the keyword table, the entire formula "breaks". Was thinking of adding placeholder keywords that would never match to allow for future growth of new rows. Example, adding a bunch of rows with ">>>Unused For Now<<<", and then changing to the "real" keyword if/when needed. Any ideas on how to fix one or both? Many thanks, Tom |
|
|
|
|
|
#8 |
|
MrExcel MVP
Moderator Contortionist Join Date: Apr 2005
Location: Hampshire, UK (Home); London, UK (Work)
Posts: 18,308
|
Hi Tom
i think the answer to both is to use Barry's formula (possibly with Aladin's modification).
__________________
Richard Schollar Microsoft MVP - Excel Need to post some data? PM me with your email address for the Beta version of the Board html maker! |
|
|
|
|
|
#9 |
|
Join Date: Jun 2008
Posts: 0
|
=index($e$2:$e$10,match(1,search("*"&$d$2:$d$10&"*",a2),0))
Ctrl-shift-enter |
|
|
|
|
|
#10 |
|
Join Date: Jun 2008
Posts: 0
|
Also, I realized that if no phrase was entered or one was accidentally deleted, I didn't have any code to catch this so I added the following:
=IF(A2="","No Phrase Entered",INDEX($E$2:$E$10,MATCH(1,SEARCH("*"&$D$2:$D$10&"*",A2),0))) confirmed with CTRL-SHIFT-ENTER |
|
|
|
![]() |
| Bookmarks |
| Thread Tools | |
| Display Modes | |
|
|