2

Is there a way to evaluate a series of formulas for a table of values without combining them into a single megaformula?

It's easier to illustrate with an example. Say Table1 looks like this:

        A        B       C            D                E          F
1    PRODUCT    COST   MARKUP    SECRET FORMULA      PRICE      PROFIT
2    burger     4.00    50%         =22*12345    =B2*(1+C2)*D2  =E2-B2
3    fries      3.00    50%         =22*12345    =B3*(1+C3)*D3  =E3-B3
4    soda       1.50    50%         =22*12345    =B4*(1+C4)*D4  =E4-B4

Now I want to build Table2 to return profit for a range of markup rates for each product, like this:

       A        B        C         D         E       F
1   MARKUP    10%       20%      30%       40%     50%
2   burger
3   fries
4   soda 

In Table2!B2, I want to want to display the value of cell Table1!$C2 when the value of cell Table1!$C2 is set to the column heading value from Table2!B$1. In other words, I want the profit for a burger when the markup is 10%. By then copying across rows and cells, I can observe the effect on profit for each item when I vary my markup from 10% to 50%.

I know I could do this manually by combining the formulas from Table 1, cols D and E into a single megaformula for Table 2. For instance, cell Table2B1 would have this formula:

= Table1!B2*(1 + B$1)*22*12345

But let's say that the SECRET FORMULA is actually a very complex series of calculations over several columns with dozens of dependencies. My actual set of formulas spans about 20 columns, and generates an 8 line formula ...impossible to edit.

So having built the series of dependent formulas in Table 1, it would be great to use those formulas to generate Table 2, without having to replicate them all in Table 2.

Ed Haywood
  • 335
  • 2
  • 9
  • 1
    Ed, the "Excel way" is to do just what you've done - break up your calculation into multiple intermediate cells. That's way prefereable to a "mega-formula" unless you are 100% certain the logic will never change (ha!). However, see options (2.5) and (3) in this answer and see if they are any help: http://stackoverflow.com/questions/4640336/using-a-sheet-in-an-excel-user-defined-function/4640866#4640866 – jtolle Jul 15 '11 at 22:08
  • Thanks. The question is how do I use those multiple intermediate cells as a calculation in another table? – Ed Haywood Jul 15 '11 at 22:12
  • Option 2.5 should do what I need. I only have one independent variable and one result, and am trying to do "what If" analysis. If you post as an answer I'll accept so you get points. Thanks. – Ed Haywood Jul 15 '11 at 22:16
  • I'm glad it helped! If you want, stick a note on your own answer to this question describing how you used a data table to solve your problem and then accept it... – jtolle Jul 15 '11 at 22:23
  • Unfortunately it turns out that option 2.5 does not do what I need. In fact, the whole data table thing seems rather silly. It does nothing that can't be done in 5 minutes by making formula dependencies absolute in corresponding rows and columns, and then copying the formula. – Ed Haywood Jul 17 '11 at 22:34
  • Ed, I can't speak directly to your situation, but the Excel data table feature does do something non-trivial. It essentially does what you'd have to by hand - substitute values into one or two cells that then have a complex series of formulas linked to them, and collect up the results of those formulas from one result cell. It would be really nice if Excel's data table feature and its scenario feature were combined, but alas... – jtolle Jul 18 '11 at 01:32

2 Answers2

1

So just to get a feel for how huge and unmanageable the megaformula is, I have posted it below:

=Table6[[#This Row],[FBLR]]*AC$1- ( ( Table6[[#This Row],[Base Salary]] + IF( IF(Table6[[#This Row],[exempt]]="Y", IF( (AC$1-'Break Even'!$D$32)>'Break Even'!$D$31, (AC$1-'Break Even'!$D$32)-'Break Even'!$D$31,0 ), (AC$1-'Break Even'!$D$32))>0, IF(Table6[[#This Row],[exempt]]="Y", IF( (AC$1-'Break Even'!$D$32)>'Break Even'!$D$31, (AC$1-'Break Even'!$D$32)-'Break Even'!$D$31,0 ), (AC$1-'Break Even'!$D$32)) *IF(Table6[[#This Row],[exempt]]="Y",Table6[[#This Row],[Pay rate]],Table6[[#This Row],[Pay rate]]*1.5), 0)) + Fringe!$D$27*IF( ( Table6[[#This Row],[Base Salary]] + IF( IF(Table6[[#This Row],[exempt]]="Y", IF( (AC$1-'Break Even'!$D$32)>'Break Even'!$D$31, (AC$1-'Break Even'!$D$32)-'Break Even'!$D$31,0 ), (AC$1-'Break Even'!$D$32))>0, IF(Table6[[#This Row],[exempt]]="Y", IF( (AC$1-'Break Even'!$D$32)>'Break Even'!$D$31, (AC$1-'Break Even'!$D$32)-'Break Even'!$D$31,0 ), (AC$1-'Break Even'!$D$32)) *IF(Table6[[#This Row],[exempt]]="Y",Table6[[#This Row],[Pay rate]],Table6[[#This Row],[Pay rate]]*1.5), 0)) > Fringe!$E$27,Fringe!$E$27, ( Table6[[#This Row],[Base Salary]] + IF( IF(Table6[[#This Row],[exempt]]="Y", IF( (AC$1-'Break Even'!$D$32)>'Break Even'!$D$31, (AC$1-'Break Even'!$D$32)-'Break Even'!$D$31,0 ), (AC$1-'Break Even'!$D$32))>0, IF(Table6[[#This Row],[exempt]]="Y", IF( (AC$1-'Break Even'!$D$32)>'Break Even'!$D$31, (AC$1-'Break Even'!$D$32)-'Break Even'!$D$31,0 ), (AC$1-'Break Even'!$D$32)) *IF(Table6[[#This Row],[exempt]]="Y",Table6[[#This Row],[Pay rate]],Table6[[#This Row],[Pay rate]]*1.5), 0)))+ ( Table6[[#This Row],[Base Salary]] + IF( IF(Table6[[#This Row],[exempt]]="Y", IF( (AC$1-'Break Even'!$D$32)>'Break Even'!$D$31, (AC$1-'Break Even'!$D$32)-'Break Even'!$D$31,0 ), (AC$1-'Break Even'!$D$32))>0, IF(Table6[[#This Row],[exempt]]="Y", IF( (AC$1-'Break Even'!$D$32)>'Break Even'!$D$31, (AC$1-'Break Even'!$D$32)-'Break Even'!$D$31,0 ), (AC$1-'Break Even'!$D$32)) *IF(Table6[[#This Row],[exempt]]="Y",Table6[[#This Row],[Pay rate]],Table6[[#This Row],[Pay rate]]*1.5), 0))*Fringe!$D$28+Fringe!$D$29*Fringe!$E$29+Fringe!$D$30*Fringe!$E$30+ IF(Table1[[#This Row],[TC?]]="Y",Fringe!$F$34*12,IF(Table1[[#This Row],[TC?]]="N",Fringe!$E$34*12*Fringe!$D$34,(Fringe!$F$34*12+Fringe!$E$34*12*Fringe!$D$34)/2)) + ( Table6[[#This Row],[Base Salary]] + IF( IF(Table6[[#This Row],[exempt]]="Y", IF( (AC$1-'Break Even'!$D$32)>'Break Even'!$D$31, (AC$1-'Break Even'!$D$32)-'Break Even'!$D$31,0 ), (AC$1-'Break Even'!$D$32))>0, IF(Table6[[#This Row],[exempt]]="Y", IF( (AC$1-'Break Even'!$D$32)>'Break Even'!$D$31, (AC$1-'Break Even'!$D$32)-'Break Even'!$D$31,0 ), (AC$1-'Break Even'!$D$32)) *IF(Table6[[#This Row],[exempt]]="Y",Table6[[#This Row],[Pay rate]],Table6[[#This Row],[Pay rate]]*1.5), 0))*Fringe!$D$32 + ( Table6[[#This Row],[Base Salary]] + IF( IF(Table6[[#This Row],[exempt]]="Y", IF( (AC$1-'Break Even'!$D$32)>'Break Even'!$D$31, (AC$1-'Break Even'!$D$32)-'Break Even'!$D$31,0 ), (AC$1-'Break Even'!$D$32))>0, IF(Table6[[#This Row],[exempt]]="Y", IF( (AC$1-'Break Even'!$D$32)>'Break Even'!$D$31, (AC$1-'Break Even'!$D$32)-'Break Even'!$D$31,0 ), (AC$1-'Break Even'!$D$32)) *IF(Table6[[#This Row],[exempt]]="Y",Table6[[#This Row],[Pay rate]],Table6[[#This Row],[Pay rate]]*1.5), 0))*Fringe!$D$33 + Fringe!$E$35*12*Fringe!$D$35 +Table1[[#This Row],[Base Salary]]*Fringe!$D$36+Fringe!$E$37*Fringe!$D$37)

Ed Haywood
  • 335
  • 2
  • 9
0

Grab the bottom border of the formula bar and drag it down, you'll get as many lines as you want for editing

enter image description here

Eric Fortis
  • 16,372
  • 6
  • 41
  • 62
  • Thanks, did that, but still impossible to maintain a formula that spans nearly the entire screen. Although the ALT+Enter will make it more readable. I will post the formula below so you can see just how big I am talking about. – Ed Haywood Jul 15 '11 at 21:31
  • @Ed Haywook OMG I was thinking 10% of that formula was a huge one. Definetely go with VBA if you need Excel, otherwise hit Alt+F4 on Excel and try with other programming language. – Eric Fortis Jul 15 '11 at 21:44
  • LOL, yeah it's an ugly one. The thing that makes it bad are all the IF formulas with dependencies. Some of the values repeat themselves a dozen times. I could probably do some factoring to shorten it up, but even that would be a long and involved process. – Ed Haywood Jul 15 '11 at 21:58
  • yep, you can make a few subroutines in VB and call them within the formula, it will look a lot prettier. "Divide and Conquer" – Eric Fortis Jul 15 '11 at 22:20