Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 23
Default Multiple Range Lookup Possible??? (Expert Level Question?)

I don't know if this is possible with some sort of lookup function
combination, but maybe somebody has an idea...


I have the following table, gauge ranges shown in the first column,
and across we have width ranges:


A1 B1 C1 D1
1-2 3-4 4-5
A2 .200-.249 1 6 9
A3 .250-.274 3 6 10
A4 .275-.300 5 7 12


I need to create a lookup function where in another sheet I have the
following

Column A Column B
Enter Gauge: .243
Enter Width: 3.5
Result: 6

Where you punch in the gauge and width and it looks it up on the table
according to range. In this case, it knows that .243 is in the first
row, and width 3.5 falls under the C column, so the result is 6.


I need to find some lookup function that finds the result, based on
the input Gauge and Width, when the table is set up in ranges. Is this
possible??
  #2   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 5,939
Default Multiple Range Lookup Possible??? (Expert Level Question?)

Yes it is possible take a look at this link...
http://www.dailydoseofexcel.com/arch...iable-lookups/
--
HTH...

Jim Thomlinson


"Naji" wrote:

I don't know if this is possible with some sort of lookup function
combination, but maybe somebody has an idea...


I have the following table, gauge ranges shown in the first column,
and across we have width ranges:


A1 B1 C1 D1
1-2 3-4 4-5
A2 .200-.249 1 6 9
A3 .250-.274 3 6 10
A4 .275-.300 5 7 12


I need to create a lookup function where in another sheet I have the
following

Column A Column B
Enter Gauge: .243
Enter Width: 3.5
Result: 6

Where you punch in the gauge and width and it looks it up on the table
according to range. In this case, it knows that .243 is in the first
row, and width 3.5 falls under the C column, so the result is 6.


I need to find some lookup function that finds the result, based on
the input Gauge and Width, when the table is set up in ranges. Is this
possible??

  #3   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 1,069
Default Multiple Range Lookup Possible??? (Expert Level Question?)

Here is one way..

Paste this custom function in a VBA module in your workbook:

Public Function WithinRange(Target As Range, CheckRange As Range, _
RowCol As String, Optional DelimitChar As Variant) As Double
Dim a As Variant, c As Range
On Error GoTo WRerr
'Use a dash if no delimiter argument was supplied.
If IsMissing(DelimitChar) Then DelimitChar = "-"
For Each c In CheckRange
a = Split(c.Value, DelimitChar)
If (CDbl(a(LBound(a))) <= CDbl(Target.Value)) And _
(CDbl(a(UBound(a))) = CDbl(Target.Value)) Then
If RowCol = "R" Then
WithinRange = c.Row
ElseIf RowCol = "C" Then
WithinRange = c.Column
End If
Exit Function
End If
Next c
'Not found. Return 0.
WithinRange = 0
Exit Function
WRerr:
'Return 0 for all errors.
WithinRange = 0
End Function

Your formula will call this function twice - once to find the correct row in
the lookup table, and once to find the column. You would call it like this:

=INDIRECT("Sheet1!" &
ADDRESS(WithinRange(B1,Sheet1!A2:A4,"R"),WithinRan ge(B2,Sheet1!B1:D1,"C")))+(NOW()*0)

In this example, Sheet1 is the name of the sheet with the lookup data. B1 is
the guage value to look up, and B2 is the width value to look up. Edit these
values as appropriate. The +(NOW()*0) forces Excel to recalculate the
formula. The "R" argument tells it to return the row number; "C" tells it to
return a column number.

The above formula will return #VALUE if the guage or width is missing or not
found in the lookup table. To return zero instead, a longer formula is needed:

=IF(OR(WithinRange(B1,Sheet1!A2:A4,"R")=0,WithinRa nge(B2,Sheet1!B1:D1,"C")=0),0,INDIRECT("Sheet1!"
&
ADDRESS(WithinRange(B1,Sheet1!A2:A4,"R"),WithinRan ge(B2,Sheet1!B1:D1,"C"))))+(NOW()*0)

If you are new to macros, this Jon Perltier link may be helpful:
http://peltiertech.com/WordPress/200...e-elses-macro/

Hope this helps,

Hutch

"Naji" wrote:

I don't know if this is possible with some sort of lookup function
combination, but maybe somebody has an idea...


I have the following table, gauge ranges shown in the first column,
and across we have width ranges:


A1 B1 C1 D1
1-2 3-4 4-5
A2 .200-.249 1 6 9
A3 .250-.274 3 6 10
A4 .275-.300 5 7 12


I need to create a lookup function where in another sheet I have the
following

Column A Column B
Enter Gauge: .243
Enter Width: 3.5
Result: 6

Where you punch in the gauge and width and it looks it up on the table
according to range. In this case, it knows that .243 is in the first
row, and width 3.5 falls under the C column, so the result is 6.


I need to find some lookup function that finds the result, based on
the input Gauge and Width, when the table is set up in ranges. Is this
possible??

  #4   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 23
Default Multiple Range Lookup Possible??? (Expert Level Question?)

Bravo Tom!! What an excellent solution...it works great!! Thanks so
much!!

Tom Hutchins wrote:
Here is one way..

Paste this custom function in a VBA module in your workbook:

Public Function WithinRange(Target As Range, CheckRange As Range, _
RowCol As String, Optional DelimitChar As Variant) As Double
Dim a As Variant, c As Range
On Error GoTo WRerr
'Use a dash if no delimiter argument was supplied.
If IsMissing(DelimitChar) Then DelimitChar = "-"
For Each c In CheckRange
a = Split(c.Value, DelimitChar)
If (CDbl(a(LBound(a))) <= CDbl(Target.Value)) And _
(CDbl(a(UBound(a))) = CDbl(Target.Value)) Then
If RowCol = "R" Then
WithinRange = c.Row
ElseIf RowCol = "C" Then
WithinRange = c.Column
End If
Exit Function
End If
Next c
'Not found. Return 0.
WithinRange = 0
Exit Function
WRerr:
'Return 0 for all errors.
WithinRange = 0
End Function

Your formula will call this function twice - once to find the correct row in
the lookup table, and once to find the column. You would call it like this:

=INDIRECT("Sheet1!" &
ADDRESS(WithinRange(B1,Sheet1!A2:A4,"R"),WithinRan ge(B2,Sheet1!B1:D1,"C")))+(NOW()*0)

In this example, Sheet1 is the name of the sheet with the lookup data. B1 is
the guage value to look up, and B2 is the width value to look up. Edit these
values as appropriate. The +(NOW()*0) forces Excel to recalculate the
formula. The "R" argument tells it to return the row number; "C" tells it to
return a column number.

The above formula will return #VALUE if the guage or width is missing or not
found in the lookup table. To return zero instead, a longer formula is needed:

=IF(OR(WithinRange(B1,Sheet1!A2:A4,"R")=0,WithinRa nge(B2,Sheet1!B1:D1,"C")=0),0,INDIRECT("Sheet1!"
&
ADDRESS(WithinRange(B1,Sheet1!A2:A4,"R"),WithinRan ge(B2,Sheet1!B1:D1,"C"))))+(NOW()*0)

If you are new to macros, this Jon Perltier link may be helpful:
http://peltiertech.com/WordPress/200...e-elses-macro/

Hope this helps,

Hutch

"Naji" wrote:

I don't know if this is possible with some sort of lookup function
combination, but maybe somebody has an idea...


I have the following table, gauge ranges shown in the first column,
and across we have width ranges:


A1 B1 C1 D1
1-2 3-4 4-5
A2 .200-.249 1 6 9
A3 .250-.274 3 6 10
A4 .275-.300 5 7 12


I need to create a lookup function where in another sheet I have the
following

Column A Column B
Enter Gauge: .243
Enter Width: 3.5
Result: 6

Where you punch in the gauge and width and it looks it up on the table
according to range. In this case, it knows that .243 is in the first
row, and width 3.5 falls under the C column, so the result is 6.


I need to find some lookup function that finds the result, based on
the input Gauge and Width, when the table is set up in ranges. Is this
possible??

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
multiple lookup including date range JonW Excel Worksheet Functions 3 February 12th 07 02:45 PM
How to lookup when range contains multiple identical entries? Doug Laidlaw Excel Discussion (Misc queries) 1 January 19th 06 12:18 PM
another EXPERT LEVEL FORMULA from me Tim Excel Discussion (Misc queries) 2 November 8th 05 11:11 AM
2-Level (criteria) Lookup Function Help Steven Leuck Excel Worksheet Functions 3 February 28th 05 06:29 PM
Multiple Criteria Lookup Question Gregg Riemer Excel Discussion (Misc queries) 3 February 22nd 05 01:18 AM


All times are GMT +1. The time now is 04:09 PM.

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

About Us

"It's about Microsoft Excel"