MrExcel Message Board

Go Back   MrExcel Message Board > Question Forums > Excel Questions

Excel Questions All Excel/VBA questions - formulas, macros, pivot tables, general help, etc. Please post to this forum in English only.

Reply
 
Thread Tools Display Modes
Old May 9th, 2002, 01:16 PM   #1
RET79
Board Regular
 
Join Date: Mar 2002
Location: England, UK.
Posts: 526
Default

Hi.

The lookup functions on excel do not satisfy my requirements.

I have two columns then data, like this:

Class Type NPols
ANN 507 100
ANN 508 123
ANN 552 6903
ANN 548 1234
ANW 507 4520
ANW 508 23520
ANW 510 2420
*** 507 5285
*** 509 2520
*** 510 2343

Now, I want to retrieve the data NPOLS for "*** 507" say so the function would pick out 5285.

Any help on this appreciated. I don't want a VBA solution sorry I want to be able to do this on the worksheet if possible.

A related problem was the following, I had data like this

Year Policy Data1 Data2
1991 Life 2345 42420
Pension 2355 2449
1992 Life 94802 42420
Pension 4295 24249
1993 Life 2420 63729
Pension 24020 74240

etc.

and I just couldn't come up with a lookup solution to find Data2 for 1992 Pension say. The required function would give me 24249.

Again, I just can't change the labels and I require a lookup solution, not VBA please.


Many thanks,

RET79

[ This Message was edited by: RET79 on 2002-05-09 12:18 ]
RET79 is offline   Reply With Quote
Old May 9th, 2002, 01:24 PM   #2
Mark W.
MrExcel MVP
 
Join Date: Feb 2002
Location: Austin, Texas USA
Posts: 11,654
Default

If your data is in A1:C11 use...

{=INDEX(C2:C11,MATCH("ASS507",A2:A11&B2:B11,0))}

...Or, if you're really determined to include the intervening space character...

{=INDEX(C2:C11,MATCH("*** 507",A2:A11&" "&B2:B11,0))}

Note: These are an array formulas which must be entered using the Control+Shift+Enter key combination. The outermost braces, { }, are not entered by you -- they're supplied by Excel in recognition of a properly entered array formula.

[ This Message was edited by: Mark W. on 2002-05-09 12:27 ]
Mark W. is offline   Reply With Quote
Old May 9th, 2002, 01:28 PM   #3
Ricky Morris
Board Regular
 
Join Date: Mar 2002
Posts: 363
Default

Quote:
On 2002-05-09 12:16, RET79 wrote:
Hi.

The lookup functions on excel do not satisfy my requirements.

I have two columns then data, like this:

Class Type NPols
ANN 507 100
ANN 508 123
ANN 552 6903
ANN 548 1234
ANW 507 4520
ANW 508 23520
ANW 510 2420
*** 507 5285
*** 509 2520
*** 510 2343

Now, I want to retrieve the data NPOLS for "*** 507" say so the function would pick out 5285.

Any help on this appreciated. I don't want a VBA solution sorry I want to be able to do this on the worksheet if possible.

A related problem was the following, I had data like this

Year Policy Data1 Data2
1991 Life 2345 42420
Pension 2355 2449
1992 Life 94802 42420
Pension 4295 24249
1993 Life 2420 63729
Pension 24020 74240

etc.

and I just couldn't come up with a lookup solution to find Data2 for 1992 Pension say. The required function would give me 24249.

Again, I just can't change the labels and I require a lookup solution, not VBA please.


Many thanks,

RET79

[ This Message was edited by: RET79 on 2002-05-09 12:18 ]
Insert a new column before Class which combines the Class & Type columns by doing =B1&C1 in column D. Now use the new column in your vlookup formula:

=Vlookup("ASS507",table,4,false)
__________________
It's never too late to learn something new.

Ricky
Ricky Morris is offline   Reply With Quote
Old May 9th, 2002, 01:28 PM   #4
Jay Petrulis
MrExcel MVP
 
Jay Petrulis's Avatar
 
Join Date: Mar 2002
Location: Chicago, IL USA
Posts: 2,042
Default

Hi,

Use INDEX and MATCH with a two-way lookup on the MATCH column.

Your data table is in A1:C9

In E1: "***" (might want to change this!)
In E2: 507

Array enter (!!) the following in your result cell
=INDEX(A1:C9,MATCH(E1&E2,A1:A9&B1:B9,0),3)

This returned 5285 for me.

Bye,
Jay
Jay Petrulis is offline   Reply With Quote
Old May 9th, 2002, 01:32 PM   #5
Jay Petrulis
MrExcel MVP
 
Jay Petrulis's Avatar
 
Join Date: Mar 2002
Location: Chicago, IL USA
Posts: 2,042
Default

Quote:
On 2002-05-09 12:24, Mark W. wrote:
If your data is in A1:C11 use...

{=INDEX(C2:C11,MATCH("ASS507",A2:A11&B2:B11,0))}

...Or, if you're really determined to include the intervening space character...

{=INDEX(C2:C11,MATCH("*** 507",A2:A11&" "&B2:B11,0))}

---snip---
Nice one! I use this multi-way lookup frequently, but never like this. Cool.
Jay Petrulis is offline   Reply With Quote
Old May 9th, 2002, 01:42 PM   #6
s-o-s
Board Regular
 
s-o-s's Avatar
 
Join Date: Apr 2002
Location: Kissimmee, Florida
Posts: 384
Default

Quote:
On 2002-05-09 12:16, RET79 wrote:
Hi.

The lookup functions on excel do not satisfy my requirements.

I have two columns then data, like this:

Class Type NPols
ANN 507 100
ANN 508 123
ANN 552 6903
ANN 548 1234
ANW 507 4520
ANW 508 23520
ANW 510 2420
*** 507 5285
*** 509 2520
*** 510 2343

Now, I want to retrieve the data NPOLS for "*** 507" say so the function would pick out 5285.

Any help on this appreciated. I don't want a VBA solution sorry I want to be able to do this on the worksheet if possible.

A related problem was the following, I had data like this

Year Policy Data1 Data2
1991 Life 2345 42420
Pension 2355 2449
1992 Life 94802 42420
Pension 4295 24249
1993 Life 2420 63729
Pension 24020 74240

etc.

and I just couldn't come up with a lookup solution to find Data2 for 1992 Pension say. The required function would give me 24249.

Again, I just can't change the labels and I require a lookup solution, not VBA please.


Many thanks,

RET79

[ This Message was edited by: RET79 on 2002-05-09 12:18 ]
Ignore the 1st part I misread the question and others have posted good alternatives.

Your 1st part of the question can be answered with,

Search Criteria is in G1 (ie *** 507)
Table is in A1:C11
3 is the 3rd column
False only picks up exact match

=vlookup(G1,A1:C11,3,False)

The 2nd part of your question looks like you need to reformat your table slightly and is then another VLookup.

Code:
     A           B    C       D    E
1 YrPol        Year Policy  Data1 Data2
2 =B2&C2      1991 Life    2345  42420
3 =B3&C3      1991 Pension 2355  2449
4 =B4&C4      1992 Life    94802 42420
5 =B5&C5      1992 Pension 4295  24249
6 =B6&C6      1993 Life    2420  63729
7 =B7&C7      1993 Pension 24020 74240
I think this is the easiest way to get a table that you can use.

Next to retrieve your values Place your query year in G1
Place your Query Type (Pension) in G2
in G3 place you formula
=vlookup(G1&G2,A1:E7,5,False)

I tested and this works.


_________________


[ This Message was edited by: s-o-s on 2002-05-09 13:34 ]
s-o-s is offline   Reply With Quote
Old May 9th, 2002, 02:08 PM   #7
Aladin Akyurek
MrExcel MVP
 
Aladin Akyurek's Avatar
 
Join Date: Feb 2002
Location: The Hague
Posts: 50,317
Default

Since you don't seem to have duplicate records for class and type (a prerequisite), you can also use:

=OFFSET(C2,SUMPRODUCT((A2:A11=E1)*(B2:B11=F1),ROW(C2:C11))-2,0,1,1)

where E1 houses a class value and F1 a type value.

Aladin
Aladin Akyurek is offline   Reply With Quote
Old May 9th, 2002, 02:22 PM   #8
RET79
Board Regular
 
Join Date: Mar 2002
Location: England, UK.
Posts: 526
Default

You guys never fail to amaze me with what you can get done on excel, WOW.

Thanks ever so much,

RET79
RET79 is offline   Reply With Quote
Old May 9th, 2002, 02:31 PM   #9
RET79
Board Regular
 
Join Date: Mar 2002
Location: England, UK.
Posts: 526
Default

Gosh this can even be extended to 3 way lookups too, amazing stuff.

RET79
RET79 is offline   Reply With Quote
Old May 9th, 2002, 02:55 PM   #10
Aladin Akyurek
MrExcel MVP
 
Aladin Akyurek's Avatar
 
Join Date: Feb 2002
Location: The Hague
Posts: 50,317
Default

A related problem was the following, I had data like this

Year Policy Data1 Data2
1991 Life 2345 42420
Pension 2355 2449
1992 Life 94802 42420
Pension 4295 24249
1993 Life 2420 63729
Pension 24020 74240

etc.

and I just couldn't come up with a lookup solution to find Data2 for 1992 Pension say. The required function would give me 24249.

Again, I just can't change the labels and I require a lookup solution, not VBA please.


This concerns thus your 2nd retrieval problem.

I'll assume that A1:D7 houses your sample data which I reproduce here:

{"Year","Policy","Data1","Data2";
1991,"Life",2345,42420;
"","Pension",2355,2449;
1992,"Life",94802,42420;
"","Pension",4295,24249;
1993,"Life",2420,63729;
"","Pension",24020,74240}

where "" stands for blank.

For a retrieval from "Data2" column, use;

=OFFSET(D2,(MATCH(F1,A:A,0)+IF(G1="Pension",1,0))-2,0,1,1)

where F1 houses a year and G1 a policy.

Aladin
Aladin Akyurek is offline   Reply With Quote
Reply

Bookmarks

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is On

Forum Jump


All times are GMT -4. The time now is 06:09 AM.


Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2012, vBulletin Solutions, Inc.
All contents Copyright 1998-2012 by MrExcel Consulting.
diabetic desserts recipes recipes Diabetic Soups Holiday Pizza Recipes Popcorn Recipes Recipes For Microwave Pasta Recipes Casserole Recipes Chili Recipes Curry Recipes Crockpot Recipes Apples Recipes Bread Recipes Vegetarian Recipes Vegetable recipes Desserts Recipes Appetizers Ethnic Recipes Meat Dishes Barbecue Recipes Sauces Recipes Marinade Recipes Low Fat Recipes Frugal Gourmet Kitchen Classics Recipes On The Grill Cook Books Seafood Recipes Cajun Recipes Breads Low Fat Low Fat Breads Bread Machine Recipes Yeast Breads Quick Breads Fat Free Vegetarian Salad Recipes Eggplant Recipes Radish Recipes Tomato Recipes Jalapeno Recipes Potato Recipes Lettuce Recipes Cabbage Recipes Beans Ambrosia Recipes Biscotti Recipes Desserts Low Fat Cookie Recipes Cheesecake Recipes Cake Recipes Pie Recipes Muffin Recipes Custard Recipes Best Appetizers Appetizers Low Fat Salsa Recipes Dip Recipes International Recipes Afghan Recipes Alaska Recipes French Recipes German Recipes Greek Recipes Italian Recipes Spanish Recipes Thai Recipes Korean Recipes Chinese Recipes Mexican Recipes Indian Recipes Beef Recipes Pork Pork & Ham Pork Butts Pork Chop Recipes Pork Ribs Rulled Pork Poultry Recipes Stews Recipes Ground Beef Barbecue Grill Barbecue Smoker All Purpose Sauce BBQ Sauce Barbecue Sauce Carolina BBQ Sauce Pickle Recipes Marinades Smoking Low Fat Appetizers & Dips Low Fat Breakfast Low Fat Cakes Low Fat Cheesecakes Low Fat Cookies Low Fat Desserts Low Fat Fish & Seafood Low Fat Meats Low Fat Pasta Low Fat Pies Low Fat Salads Low Fat Sandwiches Low Fat Sauces & Condiments Low Fat Sides Low Fat Soups Low Fat Vegetarian Baker's Dozen Taste of Home Recipe Book Bon Appetit Cookbook Blacktie Cookbook Buster Cook Book Cookbook USA Cook Book Cook Book Sara's Cookbook Sara's Cookbook Appetizers and Dips Poultry recipes Diabetic recipes Holiday recipes Miscellaneous recipes 110 recipes 1986 Usenet cookbook 2900 recipes Cyberrealm recipes Great sysops of world Specialty recipes Ceideburg recipes Cheese recipes Chili recipes Fruits recipes Garlic recipes Great chefs of NY Londontowne recipes Raisins recipes Recipes for kids US Food Vegetarian recipes Bread recipes Drinks Meat Dishes Brisket recipes Caribou recipes Chicken recipes Filet mignons recipes Pork recipes Swordfish recipes Turkey recipes Pasta recipes Uncategorized recipes Ethnic recipes Canada recipes English recipes Ethiopia recipes Germany recipes Greece recipes Mexican recipes Philippines recipes Welsh recipes Microwave recipes Soups recipes Vegetable recipes Asparagus recipes Barley recipes Brown rice recipes Lentil recipes Mushrooms recipes Salads recipes Wild rice Desserts recipes Cakes recipes Chocolate recipes Cookies recipes Ice cream recipes