Question: I have a formula in Excel that I am using to test for 7 conditions, and each condition if true will return a different value. However, I now need to test a total of 12 possible values. The limitation of the nested IFs is that you can only nest up to 7. Is there an alternative to this formula to test so that I can test for 12 values instead of 7? =IF(A1="10X12",140,IF(A1="8x8",64,IF(A1="6x6",36,IF(A1="8x10",80,IF(A1="14x16",224,IF(A1="9x9",81,IF(A1="4x3",12))))))) Answer: There is no built-in alternative formula in Excel, but you could write your own function in VBA and then call this new function instead. Let's take a look at an example. Download Excel spreadsheet (as demonstrated below)
|
In our spreadsheet, we've created a custom VBA function called CalcValue. This function accepts as a parameter a cell and returns a value based on a complex IF THEN ELSE statement. You can use this method to nest up to or more than 7 IF conditions. You can press Alt-F11 to view the VBA code. Macro Code:The macro code looks like this:
|
Visit our busy book shop, were you can find latest books for beginners as well as advanced excel users.
Spreadsheet 123 Spreadsheet Software Development
See Spreadsheets for:
a.Hotel Management b.Personal Budget
c.Corporate Finance d.Rating Calculation e.Real Estate and Mortgage
f.Web Calc