Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
DiscussionsAccessExcelInfoPathOutlookPowerPointPublisherWord
DirectoryUser Groups
Related Topics
Outlook ExpressInternet ExplorerWindowsMS Server ProductsMore Topics ...

MS Office Forum / Excel / Programming / May 2008

Tip: Looking for answers? Try searching our database.

UDF for dynamic custom lookup?

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Robin - 23 May 2008 18:56 GMT
I have a data range called Benefits.  This range does not include the header
row - that is a seperate range named BenefitHeader. The data looks something
like this:

Name               Owner   Terminated        Var1
LTC                     0         12/31/2007      TRUE
LTC                     0                                TRUE
SRP                     1         12/31/2007       EP
SRP                     0                                EP  
SRP                     1                                S162
SRP                     0                                S162    

I need to be able to lookup based on Name and any one or two of the other
columns within the named range (Currently, the columns used are A:IE and more
could be added at any time).  To do a single lookup value I would just use
=VLOOKUP("LTC",Benefits,MATCH("terminated",BenefitHeader,0))
and that would get the first instance of LTC and pull the terminated value.
However, how would I get, for example, the terminated value for SRP where
owner is 1 and Var1 is S162?  I'd like to do this without concatenating
columns, if
possible, because I want to keep it flexible when determining which columns
to use.  I am open to adding a UDF where I pass it the column headings for
values I want to specify and the column heading for the value that I would
like to get.  I think it must be possible but I don't know how to do it.  
Any help will be appreciated!!
Dave Peterson - 23 May 2008 19:54 GMT
You don't need a UDF for this.

====

Saved from a previous post:

If you want exact matches for just two columns (and return a value from a
third), you could use:

=index(othersheet!$c$1:$c$100,
  match(1,(a2=othersheet!$a$1:$a$100)
         *(b2=othersheet!$b$1:$b$100),0))

(all in one cell)

This is an array formula.  Hit ctrl-shift-enter instead of enter.  If you do it
correctly, excel will wrap curly brackets {} around your formula.  (don't type
them yourself.)

Adjust the range to match--but you can only use the whole column in xl2007.

This returns the value in othersheet column C when column A and B (of
othersheet) match A2 and B2 of the sheet with the formula.

And you can add more conditions by just adding more stuff to that product
portion of the formula:

=index(othersheet!$d$1:$d$100,
  match(1,(a2=othersheet!$a$1:$a$100)
         *(b2=othersheet!$b$1:$b$100)
         *(c2=othersheet!$c$1:$c$100),0))

> I have a data range called Benefits.  This range does not include the header
> row - that is a seperate range named BenefitHeader. The data looks something
[quoted text clipped - 21 lines]
> like to get.  I think it must be possible but I don't know how to do it.
> Any help will be appreciated!!

Signature

Dave Peterson

Dave Peterson - 23 May 2008 20:05 GMT
I see you have an active thread elsewhere.

> You don't need a UDF for this.
>
[quoted text clipped - 57 lines]
>
> Dave Peterson

Signature

Dave Peterson

Robin - 23 May 2008 22:37 GMT
Yes, I thought maybe different people look at the different forums.  I will
try your solution and see if it works.  Thanks!!

> I see you have an active thread elsewhere.
>
[quoted text clipped - 59 lines]
> >
> > Dave Peterson
Dave Peterson - 23 May 2008 23:46 GMT
It's the same solution as you got in the other newsgroup.

> Yes, I thought maybe different people look at the different forums.  I will
> try your solution and see if it works.  Thanks!!
[quoted text clipped - 66 lines]
> >
> > Dave Peterson

Signature

Dave Peterson

Bernie Deitrick - 23 May 2008 20:27 GMT
Robin,

See my reply in worksheetfunctions, though it is a VBA solution (a UDF).

HTH,
Bernie
MS Excel MVP

>I have a data range called Benefits.  This range does not include the header
> row - that is a seperate range named BenefitHeader. The data looks something
[quoted text clipped - 21 lines]
> like to get.  I think it must be possible but I don't know how to do it.
> Any help will be appreciated!!
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.