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 Apr 6th, 2002, 04:38 AM   #1
willlobb
Board Regular
 
Join Date: Mar 2002
Posts: 103
Default

Is there a limit on how many IF's you can have in an IF statement. after about seven, the formula doesnt work. if there is a limit, is there any other option? can i use something like the Case function? or can u run a macro from changing the contents of a cell?
Thanks, Will

[ This Message was edited by: willlobb on 2002-04-06 03:49 ]
willlobb is offline   Reply With Quote
Old Apr 6th, 2002, 05:25 AM   #2
Chris Davison
MrExcel MVP
 
Join Date: Feb 2002
Location: Millbank, London, UK
Posts: 1,790
Default

Just the 7 mate, then it faints
Chris Davison is offline   Reply With Quote
Old Apr 6th, 2002, 05:28 AM   #3
Chris Davison
MrExcel MVP
 
Join Date: Feb 2002
Location: Millbank, London, UK
Posts: 1,790
Default

other options inculde the use of =AND, =OR and =VLOOKUP, =HLOOKUP etc etc plus a few more I'm sure will get posted after this message

__________________
:: Pharma Z - Family drugstore ::
Chris Davison is offline   Reply With Quote
Old Apr 6th, 2002, 05:30 AM   #4
willlobb
Board Regular
 
Join Date: Mar 2002
Posts: 103
Default

ok thanks chris. can i run a macro when i click a hyperlink, or when the cell contents change?
Thanks, Will
willlobb is offline   Reply With Quote
Old Apr 6th, 2002, 05:32 AM   #5
Chris Davison
MrExcel MVP
 
Join Date: Feb 2002
Location: Millbank, London, UK
Posts: 1,790
Default

I believe both are possible, but would have to do a search to find out how as that's not my area of "expertise".... have you tried a search : I'm sure there's loads of each of these cases
__________________
:: Pharma Z - Family drugstore ::
Chris Davison is offline   Reply With Quote
Old Apr 6th, 2002, 05:58 AM   #6
Derek
Board Regular
 
Join Date: Feb 2002
Location: Perth Australia
Posts: 1,567
Default

Hi Will

Don't know about hyperlinks, but try this event macro:

Right click sheet tab, left click View Code and paste in this code:

Private Sub Worksheet_Change(ByVal Target As Range)
If Target.Address = "$D$4" Then Application.Run "Message"
End Sub

Create a normal macro called "Message" with this code

MsgBox "Your macro is running"
End Sub

Now when you change anything in cell D4 it will trigger your message macro.

Hope this helps

regards
Derek
Derek is offline   Reply With Quote
Old Apr 6th, 2002, 06:12 AM   #7
Aladin Akyurek
MrExcel MVP
 
Aladin Akyurek's Avatar
 
Join Date: Feb 2002
Location: The Hague
Posts: 50,317
Default

You can perhaps tell for what kind of task you seem to need more than 7 IFs along with a sample data and expected results.
Aladin Akyurek is offline   Reply With Quote
Old Apr 6th, 2002, 06:30 AM   #8
willlobb
Board Regular
 
Join Date: Mar 2002
Posts: 103
Default

Thanks for those other replies guys. I am making a financial computer system for a company and i have a table, 3 comlumns wide. the first column is for products sold, the second for quantity and the third for income form each product sold. the third column cotaind the formula:

=IF($D15="Bracelet Thin",$E17*0.5,IF($D15="Bracelet Thick",$E17*1,IF($D15="Bracelet Custom",$E17*1.5,IF($D15="Mouse Mats",$E17*2,IF($D15="Pebble Small",$E17*0.5,IF($D15="Pebble Large",$E17*1,IF($D15="Tree",$E17*4,IF($D15="Wendy Bell Ticket",$E17*5,""))))))))

Column D being the Product sold and E being the Quantity. I need to add more products but when i do the formula doesnt work, because like Chris said, it can only take seven.
Is there any thing i can do. Will a VLookup help? i dont really know how to use one, so if it would work, would you kindly tell me how to do it?
Thank you very much.
Will
willlobb is offline   Reply With Quote
Old Apr 6th, 2002, 07:28 AM   #9
Jay Petrulis
MrExcel MVP
 
Jay Petrulis's Avatar
 
Join Date: Mar 2002
Location: Chicago, IL USA
Posts: 2,042
Default

Quote:
On 2002-04-06 05:30, willlobb wrote:
Thanks for those other replies guys. I am making a financial computer system for a company and i have a table, 3 comlumns wide. the first column is for products sold, the second for quantity and the third for income form each product sold. the third column cotaind the formula:

=IF($D15="Bracelet Thin",$E17*0.5,IF($D15="Bracelet Thick",$E17*1,IF($D15="Bracelet Custom",$E17*1.5,IF($D15="Mouse Mats",$E17*2,IF($D15="Pebble Small",$E17*0.5,IF($D15="Pebble Large",$E17*1,IF($D15="Tree",$E17*4,IF($D15="Wendy Bell Ticket",$E17*5,""))))))))

Column D being the Product sold and E being the Quantity. I need to add more products but when i do the formula doesnt work, because like Chris said, it can only take seven.
Is there any thing i can do. Will a VLookup help? i dont really know how to use one, so if it would work, would you kindly tell me how to do it?
Thank you very much.
Will
Hi Will,

Definitely consider a Lookup table. There you list *all* the possible items and then use the lookup functions to return the price factor associated with the item. This board is filled with lookup requests so it should give you a good start.

Specifically for your nested IF statement, you cut 2 IFs by using thr OR statement for the items with equal price factors (Bracelet Thin and Pebble Small; Bracelet Thick and Pebble Large).

You can also circumvent the 7 IF limit by using booleans as in:

=(OR(D15={"Bracelet Thin","Pebble Small"})*0.5+OR(D15={"Bracelet Thick","Pebble Large"})+(D15="Bracelet Custom")*1.5+(D15="Mouse Mats")*2+(D15="Tree")*4+(D15="Wendy Bell Ticket")*5)*E17

This example can be extended and illustrates the use of the OR function within the larger formula.

Another way to overcome the 7 IF limit is to group IF statments
=IF(first 7 IFs,true,0)+IF(second 7 IFs,0)+.....

The best bet for flexibility is to use the lookup functions (VLOOKUP, HLOOKUP, LOOKUP, and INDEX/MATCH).

HTH,
Jay

Jay Petrulis is offline   Reply With Quote
Old Apr 6th, 2002, 11:41 AM   #10
Chris Davison
MrExcel MVP
 
Join Date: Feb 2002
Location: Millbank, London, UK
Posts: 1,790
Default

http://www.mrexcel.com/board/viewtop...4201&forum=2&2

try this for your hyperlink / macro enquiry..... courtesy of Mark O'Brien


__________________
:: Pharma Z - Family drugstore ::
Chris Davison 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 02:54 PM.


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