MrExcel Message Board
Support This Site


Go Back   MrExcel Message Board > The Lounge > Lounge v.2.0

Lounge v.2.0 A place to chat.

Reply
 
Thread Tools Display Modes
Old Jun 17th, 2008, 06:16 PM   #1
jonmo1
 
jonmo1's Avatar
 
Join Date: Oct 2006
Location: Bryan, TX
Posts: 14,397
Default Re: June/July 2008 Challenge of the Month

Quote:
there is a string of ascii characters at the end of each cell - a bunch of 160s (not sure what this is) ending with a 32 (space). i think mr excel is messing with our minds!
Hmm, LOL. I thought maybe it was an accident or problem with the download of the file...

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.
jonmo1 is offline   Reply With Quote
Old Jun 17th, 2008, 06:05 PM   #2
Aladin Akyurek
MrExcel MVP
 
Aladin Akyurek's Avatar
 
Join Date: Feb 2002
Location: The Hague
Posts: 39,500
Default Re: June/July 2008 Challenge of the Month

Quote:
Originally Posted by schielrn View Post
Aladin,

I could only get your formula to work for the phrases that did not end with the color. The only way I could get it to work in all cases if the phrase ends with the color was by removing the &" "

=LOOKUP(9.99999999999999E+307,SEARCH(" "&$D$2:$D$10," "&A2),$E$2:$E$10)
Given Bill's data...

PhrasesAssignmentsKeywordAssigned to
the ocean is blueJoeblueJoe
I like the freddy shirt#N/AredBob
blue is my favorite colorJoeyellowMary
the ocean is redBobpinkFred
I like his red shirtBoborangeRalph
red is my favorite colorBobbrownLora
the ocean is yellowMarywhiteTracy
I like his yellow shirtMarylavendarEarl
yellow is my favorite colorMarymagentaJenny
the ocean is pinkFred
I like his pink shirtFred
#N/A


=LOOKUP(9.99999999999999E+307,SEARCH(" "&$D$2:$D$10&" "," "&A2&" "),$E$2:$E$10)

should simply work.
Aladin Akyurek is offline   Reply With Quote
Old Jun 17th, 2008, 06:07 PM   #3
cornflakegirl
 
cornflakegirl's Avatar
 
Join Date: Nov 2004
Location: UK
Posts: 1,743
Default Re: June/July 2008 Challenge of the Month

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))
will work - but it's nasty!
__________________
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.
cornflakegirl is offline   Reply With Quote
Old Jun 17th, 2008, 06:10 PM   #4
schielrn
 
schielrn's Avatar
 
Join Date: Apr 2007
Location: Cincinnati, Ohio
Posts: 5,337
Default Re: June/July 2008 Challenge of the Month

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!
schielrn is offline   Reply With Quote
Old Jun 17th, 2008, 06:17 PM   #5
Aladin Akyurek
MrExcel MVP
 
Aladin Akyurek's Avatar
 
Join Date: Feb 2002
Location: The Hague
Posts: 39,500
Default Re: June/July 2008 Challenge of the Month

Quote:
Originally Posted by cornflakegirl View Post
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))
will work - but it's nasty!
Emma,

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)
Aladin Akyurek is offline   Reply With Quote
Old Jun 18th, 2008, 09:23 PM   #6
arkusM
 
arkusM's Avatar
 
Join Date: Apr 2007
Location: Calgary, Alberta
Posts: 317
Default Re: June/July 2008 Challenge of the Month

Aladin,
I am running XL2003 and have no issue with the first posted formula. It works perfectly.

M


Quote:
Originally Posted by Aladin Akyurek View Post
You'd need to invoke a formula of the type as in:

http://www.mrexcel.com/forum/showthread.php?t=321942

http://www.mrexcel.com/forum/showthread.php?t=323188


Applied to the problem/task at hand...

Code:
=LOOKUP(9.99999999999999E+307,
    SEARCH(" "&$D$2:$D$10&" "," "&A2&" "),
    $E$2:$E$10)
On Excel 2003 and beyond, convert D2:E10 into a list (Data|List|CreateList).

On earlier version, we would need define dynamic named ranges, say, KEYS and SLOTS, and invoke:

Code:
=LOOKUP(9.99999999999999E+307,
    SEARCH(" "&KEYS&" "," "&A2&" "),
    SLOTS)
__________________

"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
arkusM is offline   Reply With Quote
Old Jun 19th, 2008, 05:11 AM   #7
tjmcgough
 
Join Date: Jun 2008
Posts: 0
Default Re: June/July 2008 Challenge of the Month

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
tjmcgough is offline   Reply With Quote
Old Jun 19th, 2008, 09:41 AM   #8
RichardSchollar
MrExcel MVP
Moderator
Contortionist
 
RichardSchollar's Avatar
 
Join Date: Apr 2005
Location: Hampshire, UK (Home); London, UK (Work)
Posts: 18,308
Default Re: June/July 2008 Challenge of the Month

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!



RichardSchollar is offline   Reply With Quote
Old Jun 19th, 2008, 02:30 PM   #9
rgdwar1
 
Join Date: Jun 2008
Posts: 0
Default Re: June/July 2008 Challenge of the Month

=index($e$2:$e$10,match(1,search("*"&$d$2:$d$10&"*",a2),0))

Ctrl-shift-enter
rgdwar1 is offline   Reply With Quote
Old Jun 19th, 2008, 03:39 PM   #10
rgdwar1
 
Join Date: Jun 2008
Posts: 0
Default Re: June/July 2008 Challenge of the Month

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
rgdwar1 is offline   Reply With Quote
Reply

Bookmarks

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is On

Forum Jump


All times are GMT +1. The time now is 11:04 PM.


Powered by vBulletin® Version 3.8.4
Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
All contents Copyright 1998-2009 by MrExcel Consulting.