IF Statements Help - DESPARATELY NEED HELP!!

willlobb

Board Regular
Joined
Mar 29, 2002
Messages
103
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
 

Excel Facts

When did Power Query debut in Excel?
Although it was an add-in in Excel 2010 & Excel 2013, Power Query became a part of Excel in 2016, in Data, Get & Transform Data.
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
 
Upvote 0
ok thanks chris. can i run a macro when i click a hyperlink, or when the cell contents change?
Thanks, Will
 
Upvote 0
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
 
Upvote 0
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
 
Upvote 0
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.
 
Upvote 0
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
 
Upvote 0
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
 
Upvote 0

Forum statistics

Threads
1,213,567
Messages
6,114,342
Members
448,570
Latest member
rik81h

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top