Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3
Default lookup function with 2 parameter in VBA ?

Hi,

on sheet2, i have the following table
col1 col2 col3
A 1 10
A 2 11
B 1 20
B 2 25
C 1 30
C 2 32
....

on sheet1, i have the following table

col1 col2 col3
A 2
B 1
A 1
C 1

i would like in col3 the result of the search...something like
research on sheet 2 the couple sheet1:col1 and sheet1:col2
if found sheet1:col3 = result of research

this exist vis LOOKUP function, but it does not allow a research based on 2
parameter...
how can i do it ?

thanks a lot for help

Maileen
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 74
Default lookup function with 2 parameter in VBA ?

Maileen,

The simplest way I know is to insert another column on the table you are
looking up into (to the left of the column with the value you are looking up)
that concatenates col1 & 2 and perform the vlookup against this column
(concatenating the 2 cells that make up the key in the vlookup function
itself).

You can do some more funky stuff with SUMPRODUCT & array formulae, but the
above suffices for me most of the time.

Regards,

Chris.
--
Chris Marlow
MCSD.NET, Microsoft Office XP Master


"Maileen" wrote:

Hi,

on sheet2, i have the following table
col1 col2 col3
A 1 10
A 2 11
B 1 20
B 2 25
C 1 30
C 2 32
....

on sheet1, i have the following table

col1 col2 col3
A 2
B 1
A 1
C 1

i would like in col3 the result of the search...something like
research on sheet 2 the couple sheet1:col1 and sheet1:col2
if found sheet1:col3 = result of research

this exist vis LOOKUP function, but it does not allow a research based on 2
parameter...
how can i do it ?

thanks a lot for help

Maileen

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,272
Default lookup function with 2 parameter in VBA ?

=INDEX(Sheet1!C1:C100,MATCH((Sheet1!A1:A100=A1)*(S heet1!B1:B100=B1),Sheet1!C
1:C100,0)

which is an array formula, it should be committed with Ctrl-Shift-Enter, not
just Enter.

--
HTH

Bob Phillips

(remove nothere from email address if mailing direct)

"Maileen" wrote in message
...
Hi,

on sheet2, i have the following table
col1 col2 col3
A 1 10
A 2 11
B 1 20
B 2 25
C 1 30
C 2 32
...

on sheet1, i have the following table

col1 col2 col3
A 2
B 1
A 1
C 1

i would like in col3 the result of the search...something like
research on sheet 2 the couple sheet1:col1 and sheet1:col2
if found sheet1:col3 = result of research

this exist vis LOOKUP function, but it does not allow a research based on

2
parameter...
how can i do it ?

thanks a lot for help

Maileen



  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35,218
Default lookup function with 2 parameter in VBA ?

You have a reply in .misc.

Maileen wrote:

Hi,

on sheet2, i have the following table
col1 col2 col3
A 1 10
A 2 11
B 1 20
B 2 25
C 1 30
C 2 32
...

on sheet1, i have the following table

col1 col2 col3
A 2
B 1
A 1
C 1

i would like in col3 the result of the search...something like
research on sheet 2 the couple sheet1:col1 and sheet1:col2
if found sheet1:col3 = result of research

this exist vis LOOKUP function, but it does not allow a research based on 2
parameter...
how can i do it ?

thanks a lot for help

Maileen


--

Dave Peterson
  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35,218
Default lookup function with 2 parameter in VBA ?

..excel. Sorry.

Dave Peterson wrote:

You have a reply in .misc.

Maileen wrote:



  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 718
Default lookup function with 2 parameter in VBA ?

IMHO, the best way would be to create "hidden" columns on each sheet, with a
formula like:
=A1&"|"&B1

Then yo can use LOOKUP function based on those combo columns.

HTH,
--
AP

"Maileen" a écrit dans le message de
...
Hi,

on sheet2, i have the following table
col1 col2 col3
A 1 10
A 2 11
B 1 20
B 2 25
C 1 30
C 2 32
...

on sheet1, i have the following table

col1 col2 col3
A 2
B 1
A 1
C 1

i would like in col3 the result of the search...something like
research on sheet 2 the couple sheet1:col1 and sheet1:col2
if found sheet1:col3 = result of research

this exist vis LOOKUP function, but it does not allow a research based on

2
parameter...
how can i do it ?

thanks a lot for help

Maileen



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 funtion: column index number (third parameter) KipB Excel Worksheet Functions 8 February 3rd 07 11:57 AM
Cell contents as the 'lookup value' parameter in HLOOKUP function EMarre Excel Discussion (Misc queries) 3 August 30th 05 03:49 PM
Function parameter description Davids Excel Programming 2 May 2nd 05 02:17 PM
Excel VBA Function Parameter Overwritten Flystar Excel Programming 6 May 10th 04 08:30 AM
Function parameter description Christine[_5_] Excel Programming 1 November 27th 03 06:08 PM


All times are GMT +1. The time now is 01:31 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"