Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Excel v-lookup referencing part of a text in a cell.

Posted on 2013-02-03
15
Medium Priority
?
286 Views
Last Modified: 2013-02-10
I am trying to use v-lookup to search part of the text in a cell and have the information displayed.

The formula is entered in cell is J2 in sheet2 and contains urls like the ones listed  below

www.acs.acct/mus.com <  i.e I would like to match ACCT to column N in spreadsheet 2 >
www.org.estm/cst.com 
www.can.logon/can.com


The array looks like this which is on spreadsheet sheet 2

      column N  column O
     -----------    ------------
1.   acct            Account
2.   estm          Estatement
3.   logon         Logon

Here is the formula I attempted to use

=  Vlookup ( "*" & H1 & "*",  sheet3!N1:011,2,False

Nothing happen, is there a way to do a vlookup by referencing part of a text in a cell.
0
Comment
Question by:DAN2011
  • 6
  • 4
  • 3
  • +1
15 Comments
 
LVL 24

Expert Comment

by:Steve
ID: 38850180
Try the follwoing to get just the "acct"...

=MID(H1,FIND(".",H1,5)+1,FIND("/",H1)-FIND(".",H1,5)-1)

in the lookup it would be:

=VLOOKUP(MID(H1,FIND(".",H1,5)+1,FIND("/",H1)-FIND(".",H1,5)-1), sheet3!$N$1:$0$11,2,False)
Example.xlsx
0
 
LVL 16

Expert Comment

by:terencino
ID: 38850704
Or you could use a simple array formula like so...
Lookup array formulaEnter the formula into the first cell, then hit Ctrl+Shift+Enter all at the same time to enter it as an array formula with the {curly brackets} then drag down the rest of the cells
...Terry
ArrayFormulaLookup.xlsx
0
 
LVL 24

Expert Comment

by:Steve
ID: 38850783
Nice suggestion Terry, I like it... although...

Need to add '$' to the formula to make sure that the lookup range does not increment as you drag...
=IF(FIND(B$1:B$3,B6)>0,C$1:C$3,"")

And upon doing this the formula sems to fail... am I doing something wrong?
0
Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

 
LVL 16

Expert Comment

by:terencino
ID: 38850790
Good pickup The_Barman thank you!
Usually I would name the ranges
0
 
LVL 50

Expert Comment

by:barry houdini
ID: 38850837
As The_Barman says, though, if you fix the references or name the ranges then the results in C6/C7 are errors - the formula only works in cases where the first row is a match.

Perhaps try this "non-array" version

=LOOKUP(2^15,FIND("."&B$1:B$3&"/",B5),C$1:C$3)

regards, barry
0
 
LVL 24

Expert Comment

by:Steve
ID: 38850839
you could use :

=INDEX($C$1:$C$3,MAX(IF(ISERROR(FIND($B$1:$B$3,B6)),-1,1)*(ROW($B$1:$B$3)-ROW($B$1)+1)))


But (as ever) Barry smacks this one out of the park... nice formula Barry :)

And as ever, I must ask... Barry... How does that work (in particular the "2^15")??
ArrayFormulaLookup.xlsx
0
 
LVL 50

Expert Comment

by:barry houdini
ID: 38850875
Thanks Steve, my suggestion uses the same principle as this formula

=LOOKUP(9.99E+307,A1:A10,Z1:Z10)

That finds the last number in A1:A10 and returns the corresponding value in Z1:Z10. That works because 9.99E+307 is (almost) the largest number you can enter in a cell in Excel so, assuming no number that large is found in A1:A10 it always matches with the last number (ignoring any text or errors).

In this version.....

=LOOKUP(2^15,FIND("."&B$1:B$3&"/",B5),C$1:C$3)

....notice that FIND is looking for the lookup values surrounded by comma and forward slash, thereby avoiding any false matches. FIND will produce an error or a number - the number being limited by the maximum number of characters in a cell - which is 2^15-1

.....So you can use 2^15 as lookup value and you know that it will be greater than any number returned by FIND.

Of course if there is more than one match you'll get the last one (unlike VLOOKUP which will give you the first match)

regards, barry
0
 
LVL 24

Expert Comment

by:Steve
ID: 38850885
Well, that is my one thing learned for the day.

Thanks for the explanation Barry.
Another tool to add to my repertoire.

ATB
Steve.
0
 

Author Comment

by:DAN2011
ID: 38858099
when i tried the formula
=LOOKUP(2^15,FIND("."&B$1:B$3&"/",B5),C$1:C$3) /I got N/A

=INDEX($C$1:$C$3,MAX(IF(ISERROR(FIND($B$1:$B$3,B6)),-1,1)*(ROW($B$1:$B$3)-ROW($B$1)+1)))/I got n/A #VALUE!/

=IF(FIND(B$1:B$3,B6)>0,C$1:C$3,"") / did not  produce a result.

For example if the URL was
The url                                   The lookup value would be      To Be displayed in J1

www.online.act.exp.com        act                                              Account

Thanks
0
 
LVL 16

Expert Comment

by:terencino
ID: 38858103
For the middle formula did you enter it as an array formula (pressing Ctrl+Shift+Enter instead of Enter)?
0
 

Author Comment

by:DAN2011
ID: 38858144
I tried hardcoding the lookup with the code ----> lookup("*act*",$AI$1:$AJ$12,2,False)  which worked partially.  I got the result Account, however this only account for the urls that contains act. Is it away to hardcode multiple values?
0
 
LVL 16

Expert Comment

by:terencino
ID: 38858149
Did you change the ranges in the formulas to match your ranges? Can you send a sample of the spreadsheet you are using, that will help with setting up the formulas correctly for you
0
 
LVL 24

Expert Comment

by:Steve
ID: 38858391
OK, BarryHoudinis formula works based upon the question asked... but the adress has changed as it no longer has '\' in it... try...

=LOOKUP(2^15,FIND(B$1:B$3,B5),C$1:C$3)
ArrayFormulaLookup.xlsx
0
 

Author Comment

by:DAN2011
ID: 38862741
Attached  is a sample of the spreadsheet. FYI, the actual maximum rows is 2000 and the url varies. The first row is a example.

In the example, est in found in the URL(column b) in row one on sheet1.  I would like est to be looked up from the table displayed in the second sheet(lookup) and have eStatement displayed in column c of the first sheet. The lookup table does not have to be in the second sheet like it is in the attached example it can be  on the first worksheet if you see fit, as long as it appears  in a  distant column like AI.
Workbookexp.xlsx
0
 
LVL 24

Accepted Solution

by:
Steve earned 2000 total points
ID: 38862918
Attached is your original file with the working formula...
Note the case sensitivity in first original file.

I have also attached a two formula workbook...
This includes dynamic ranges (bold) and no case sensitivity in both.
Workbookexp.xlsx
Workbookexp.xlsx
0

Featured Post

Keep up with what's happening at Experts Exchange!

Sign up to receive Decoded, a new monthly digest with product updates, feature release info, continuing education opportunities, and more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

If you need to forecast numbers -- typically for finance -- the Windows and Mac versions of Excel 2016 have a basket of tools to get the job done.
Windows Explorer lets you open cabinet (cab) files like any other folder. In VBA you can easily handle normal files and folders, but opening and indeed creating cabinet files takes a lot more - and that's you'll find here.
This Micro Tutorial will demonstrate how to use a scrolling table in Microsoft Excel using the INDEX function.
Although Jacob Bernoulli (1654-1705) has been credited as the creator of "Binomial Distribution Table", Gottfried Leibniz (1646-1716) did his dissertation on the subject in 1666; Leibniz you may recall is the co-inventor of "Calculus" and beat Isaac…

972 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question