Solved

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

Posted on 2013-02-03
15
275 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
Comment Utility
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
Comment Utility
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
Comment Utility
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
 
LVL 16

Expert Comment

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

Expert Comment

by:barry houdini
Comment Utility
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
Comment Utility
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
Comment Utility
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
How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

 
LVL 24

Expert Comment

by:Steve
Comment Utility
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
Comment Utility
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
Comment Utility
For the middle formula did you enter it as an array formula (pressing Ctrl+Shift+Enter instead of Enter)?
0
 

Author Comment

by:DAN2011
Comment Utility
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
Comment Utility
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
Comment Utility
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
Comment Utility
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 500 total points
Comment Utility
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

What Is Threat Intelligence?

Threat intelligence is often discussed, but rarely understood. Starting with a precise definition, along with clear business goals, is essential.

Join & Write a Comment

PaperPort has a feature called the "Send To Bar". It provides a convenient, drag-and-drop interface for using other installed software, such as Microsoft Office. However, this article shows that the latest Office 2016 apps (installed with an Office …
This article will show you how to use shortcut menus in the Access run-time environment.
This Micro Tutorial demonstrate the bugs in Microsoft Excel for Mac with Pivot Charts.
This Micro Tutorial will demonstrate how to use longer labels with horizontal bar charts instead of the vertical column chart.

744 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

Need Help in Real-Time?

Connect with top rated Experts

17 Experts available now in Live!

Get 1:1 Help Now