MrExcel Message Board


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, 01:30 PM   #1
MrExcel
.
 
MrExcel's Avatar
 
Join Date: Feb 2002
Location: Akron, Ohio USA
Posts: 729
Default ***WINNERS ANNOUNCEMENT*** June/July 2008 Challenge of the Month

I've posted a new challenge of the month today. Like the last challenge, this one will have many different approaches. Post your entries here. While the ultimate "best" entry wins the LiveLessons DVD, several podcast DVD's are available to anyone who proposes a significant advancement towards a cool solution.

Entries are due by 15 July 2008.

Bill Jelen


***WINNERS LIST PUBLISHED HERE***

http://www.mrexcel.com/pc18.shtml
__________________
Preview my latest book for Free

Last edited by RichardSchollar; Mar 13th, 2009 at 11:33 PM.
MrExcel is offline   Reply With Quote
Old Jun 17th, 2008, 02:09 PM   #2
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

Looks like I get to be first:

Entered in B2 copied down as far as required (matches against the last colour occurrence in the cell):

=INDEX($E$2:$E$10,MAX(ISNUMBER(SEARCH($D$2:$D$10,A2))*(ROW($D$2:$D$10)-ROW($D$2)+1)))

Confirmed with Ctrl+Shift+Enter


This one matches against the first colour occurrence in the cell):

=INDEX($E$2:$E$10,MATCH(TRUE,ISNUMBER(SEARCH($D$2:$D$10,$A2)),0))

Confirmed with Ctrl+Shift+Enter
__________________
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!




Last edited by RichardSchollar; Jun 17th, 2008 at 02:20 PM.
RichardSchollar is offline   Reply With Quote
Old Jun 17th, 2008, 02:46 PM   #3
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

In case of multiple occurrences of individual colours (could include submatches too eg red and redditch) the following will select the name against the colour with the highest number of occurrences:

=INDEX($E$2:$E$10,SUMPRODUCT(MAX(((LEN($A2)-LEN(SUBSTITUTE($A2,$D$2:$D$10,"")))/LEN($D$2:$D$10)=MAX((LEN($A2)-LEN(SUBSTITUTE($A2,$D$2:$D$10,"")))/LEN($D$2:$D$10)))*(ROW($D$2:$D$10)-ROW($D$2)+1))))

Confirmed with Ctrl+Shift+Enter
__________________
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 17th, 2008, 03:07 PM   #4
Oorang
 
Oorang's Avatar
 
Join Date: Mar 2005
Posts: 2,055
Talking Re: June/July 2008 Challenge of the Month

Got caught by the edit thingy. The full post should have been:


I did the challenge before I looked at the thread so this may have some overlap on RS but it's a bit different so I posted it anyway.

It will find the first occurrence of any color in the color range in the cell's value and vlookup on that value. Place in B2 and copy down. Returns #VALUE! on fail.

=VLOOKUP(INDEX($E$2:$E$10,SUMPRODUCT(--NOT(ISERROR(SEARCH($E$2:$E$10,A2))),ROW(INDIRECT("1:" & ROWS($E$2:$E$10))))-1),$E$2:$F$10,2)
__________________
  • Get better answers! Include your version of Office in your post.
Oorang is offline   Reply With Quote
Old Jun 17th, 2008, 03:11 PM   #5
barry houdini
MrExcel MVP
 
Join Date: Mar 2005
Location: England
Posts: 13,901
Default Re: June/July 2008 Challenge of the Month

Here's one possibility.....

=LOOKUP(2^15,SEARCH(D$2:D$10,A2),E$2:E$10)
barry houdini is offline   Reply With Quote
Old Jun 17th, 2008, 03:15 PM   #6
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

That's great Barry!
__________________
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 17th, 2008, 03:30 PM   #7
gingerafro
 
Join Date: Mar 2005
Location: West Sussex, England
Posts: 440
Default Re: June/July 2008 Challenge of the Month

Quote:
Originally Posted by barry houdini View Post
Here's one possibility.....

=LOOKUP(2^15,SEARCH(D$2:D$10,A2),E$2:E$10)
taken a few minutes to get my head round it, but that is quality.
__________________
Its all about whats in your toolbox.
I'll lend you my hammer.
One day I might call to borrow your screwdriver.
gingerafro is offline   Reply With Quote
Old Jun 17th, 2008, 03:59 PM   #8
schielrn
 
schielrn's Avatar
 
Join Date: Apr 2007
Location: Cincinnati, Ohio
Posts: 5,337
Default Re: June/July 2008 Challenge of the Month

Here's a VBA approach:

Code:
Sub returnName()
For i = 2 To Cells(Rows.Count, 1).End(xlUp).Row
    For j = 2 To Cells(Rows.Count, 4).End(xlUp).Row
        If InStr(1,Cells(i, 1).Value, Cells(j, 4).Value) Then Cells(i, 2).Value = Cells(j, 5).Value
    Next j
Next i
End Sub
__________________
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, 04:02 PM   #9
Jon von der Heyden
 
Jon von der Heyden's Avatar
 
Join Date: Sep 2004
Location: Hampshire, England
Posts: 3,822
Default Re: June/July 2008 Challenge of the Month

Yes very slick indeed, although I must ask, why have you specifically used 2^15? I understand the bignum concept, only most people seem to use 9.99999999999999E+307. Was there particular purpose or did you just throw it in knowing that it would be large enough?

Regards
Jon
__________________
Regards


Jon (XP Pro v.2002, XL2003)
Jon von der Heyden is offline   Reply With Quote
Old Jun 17th, 2008, 04:07 PM   #10
jonmo1
 
jonmo1's Avatar
 
Join Date: Oct 2006
Location: Bryan, TX
Posts: 14,397
Default Re: June/July 2008 Challenge of the Month

Well, since no one else did a VBA UDF solution...Maybe I'll be the first to do that..

formula in B2 filled down is

=Jonmo1(A2,D:E)

Code:
Public Function Jonmo1(C As Range, L As Range)
Dim MyArray As Variant
Dim X As Long, Y
MyArray = Split(C, " ")
Jonmo1 = ""
For X = LBound(MyArray) To UBound(MyArray)
    Y = Application.Match(MyArray(X), 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
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 09:32 AM.


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