Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 210
Default UDF for dynamic custom lookup?

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",Benefit Header,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!!

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35,218
Default UDF for dynamic custom lookup?

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))

Robin wrote:

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",Benefit Header,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
  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35,218
Default UDF for dynamic custom lookup?

I see you have an active thread elsewhere.

Dave Peterson wrote:

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))

Robin wrote:

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",Benefit Header,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


--

Dave Peterson
  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,441
Default UDF for dynamic custom lookup?

Robin,

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

HTH,
Bernie
MS Excel MVP


"Robin" wrote in message
...
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",Benefit Header,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!!



  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 210
Default UDF for dynamic custom lookup?

Yes, I thought maybe different people look at the different forums. I will
try your solution and see if it works. Thanks!!

"Dave Peterson" wrote:

I see you have an active thread elsewhere.

Dave Peterson wrote:

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))

Robin wrote:

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",Benefit Header,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


--

Dave Peterson



  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35,218
Default UDF for dynamic custom lookup?

It's the same solution as you got in the other newsgroup.

Robin wrote:

Yes, I thought maybe different people look at the different forums. I will
try your solution and see if it works. Thanks!!

"Dave Peterson" wrote:

I see you have an active thread elsewhere.

Dave Peterson wrote:

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))

Robin wrote:

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",Benefit Header,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


--

Dave Peterson


--

Dave Peterson
Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Lookup Dynamic Value in a Table Thomas M. Excel Worksheet Functions 8 April 29th 09 09:25 PM
Dynamic Custom Number Format Cordell Excel Discussion (Misc queries) 2 July 25th 08 09:26 PM
Dynamic Worksheet Lookup Salman Excel Worksheet Functions 1 November 20th 06 07:28 AM
dynamic lookup Giantrobot Excel Worksheet Functions 3 June 17th 06 12:11 AM
using LOOKUP instead of IF on dynamic row Jay C Excel Worksheet Functions 0 April 8th 05 12:56 PM


All times are GMT +1. The time now is 07:08 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"