Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Double lookup

Hi,

I have a spreadsheet (excel 2000) and it has headings and subheadings in
column A, with values in column B. As shown below:

AAA
Product 1 20
Product 2 30
Product 3 40
BBB
Product 1 10
Product 2 15
Product 3 20

What I need is to perform a lookup or search that recognises the heading,
and finds the correct subheading, and displays the value next to that
subheading. i.e.:

If I want "BBB" heading, and "Product 1" subheading, the value displayed
would be 10.

I have been trying to use the find function to find the heading, but cannot
find code to search the Subheading:
Cells.Find("BBB", , xlValues).Activate

I have been rattling my brain trying to find any formula or code to perform
this, any help would be much appreciated.

Thank you in-advance.
Matt

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,651
Default Double lookup

On Tue, 28 Nov 2006 04:03:01 -0800, MattPrpich
wrote:

Hi,

I have a spreadsheet (excel 2000) and it has headings and subheadings in
column A, with values in column B. As shown below:

AAA
Product 1 20
Product 2 30
Product 3 40
BBB
Product 1 10
Product 2 15
Product 3 20

What I need is to perform a lookup or search that recognises the heading,
and finds the correct subheading, and displays the value next to that
subheading. i.e.:

If I want "BBB" heading, and "Product 1" subheading, the value displayed
would be 10.

I have been trying to use the find function to find the heading, but cannot
find code to search the Subheading:
Cells.Find("BBB", , xlValues).Activate

I have been rattling my brain trying to find any formula or code to perform
this, any help would be much appreciated.

Thank you in-advance.
Matt



How do you differentiate a Heading from a SubHeading?

Once you define that, one solution would be to read the table from the
worksheet into an array with three dimensions (Heading, subheading, values).
It should then be fairly simple to do your lookup.


--ron
  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 318
Default Double lookup

Hi
See if this function meets your requirement

Function MyLookup(ByVal sHeading$, ByVal sSubHeading$) As String
Dim r As Range, r2 As Range, r3 As Range
Set r = Sheet1.Range("A:A").Find(What:=sHeading, LookIn:=xlValues,
LookAt:=xlWhole, MatchByte:=True)
If Not (r Is Nothing) Then
If r.Offset(1, 1).Value < "" Then
If r.Offset(2, 1).Value = "" Then
Set r2 = r.Offset(1, 1)
Else
Set r2 = r.Offset(1, 1).Resize(r.Offset(1,
1).End(xlDown).Row - r.Offset(1, 1).Row + 1)
End If
Set r3 = r2.Find(What:=sSubHeading, LookIn:=xlValues,
LookAt:=xlWhole, MatchByte:=True)
If Not (r3 Is Nothing) Then
MyLookup = r3.Offset(0, 1).Value
End If
End If
End If
End Function


"MattPrpich" wrote:

Hi,

I have a spreadsheet (excel 2000) and it has headings and subheadings in
column A, with values in column B. As shown below:

AAA
Product 1 20
Product 2 30
Product 3 40
BBB
Product 1 10
Product 2 15
Product 3 20

What I need is to perform a lookup or search that recognises the heading,
and finds the correct subheading, and displays the value next to that
subheading. i.e.:

If I want "BBB" heading, and "Product 1" subheading, the value displayed
would be 10.

I have been trying to use the find function to find the heading, but cannot
find code to search the Subheading:
Cells.Find("BBB", , xlValues).Activate

I have been rattling my brain trying to find any formula or code to perform
this, any help would be much appreciated.

Thank you in-advance.
Matt

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
Double Lookup Teddy-B Excel Discussion (Misc queries) 3 October 19th 09 07:06 PM
Double Lookup SteveR Excel Worksheet Functions 6 November 14th 08 11:12 AM
Variable Lookup/Double Lookup Ryan[_2_] Excel Worksheet Functions 8 May 14th 07 09:44 PM
Double LOOKUP? Help please... mitchy Excel Worksheet Functions 2 March 20th 06 03:05 PM
Double lookup Dean[_8_] Excel Programming 3 July 26th 05 09:25 AM


All times are GMT +1. The time now is 01:32 AM.

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"