JenniferMurphy
Well-known Member
- Joined
- Jul 23, 2011
- Messages
- 2,531
- Office Version
- 365
- Platform
- Windows
I would like to to do some fairly complicated calculations in a UDF. And I would like to do them using named ranges, if possible.
Here's a sample table. The input data is in Columns D, E, & F. These columns have been assigned the names T, A, & B. Column G contains the calculated result. The formulas in Column G are shown in Column H. Each result in G is calculated from the data in the 2x3 range of cells in Columns D, E, & F and the current row plus the previous row. For example, the data in G4 is calculated from the data in cells D4:F5. For the last row, the "previous" row is the top row, so the value in G8 is calculated from the data in cells D8:F8 & D4:F4.
<tbody>
</tbody>
Column I shows the UDF call I would like to be able to make. Column J shows the original equation that I am trying to implement. I would like the code in the UDF to look as much like that equation as possible.
If I could make the code in the sheet look like that equation, I probably wouldn't need the UDF.
Note that the results are added from the bottom up. New results are added at the top.
Thanks for any help...
Here's a sample table. The input data is in Columns D, E, & F. These columns have been assigned the names T, A, & B. Column G contains the calculated result. The formulas in Column G are shown in Column H. Each result in G is calculated from the data in the 2x3 range of cells in Columns D, E, & F and the current row plus the previous row. For example, the data in G4 is calculated from the data in cells D4:F5. For the last row, the "previous" row is the top row, so the value in G8 is calculated from the data in cells D8:F8 & D4:F4.
R/C | C | D | E | F | G | H | I | J |
3 | # | T | A | B | X | Formula in Col G | UDF | Original Equation |
4 | 5 | 82.42 | 20 | 3 | 3.52 | =(D4*F5-D5*F4)/(E4*F5-E5*F4) | =MyUDF(T,A,B) | =(T4*B5 - T5*B4)/(A4*B5 - A5*B4) |
5 | 4 | 33.09 | 6 | 3 | 0.99 | =(D5*F6-D6*F5)/(E5*F6-E6*F5) | =MyUDF(T,A,B) | =(T5*B6 - T6*B5)/(A5*B6 - A6*B5) |
6 | 3 | 35.07 | 8 | 3 | 3.77 | =(D6*F7-D7*F6)/(E6*F7-E7*F6) | =MyUDF(T,A,B) | =(T6*B7 - T7*B6)/(A6*B7 - A7*B6) |
7 | 2 | 27.54 | 6 | 3 | 3.65 | =(D7*F8-D8*F7)/(E7*F8-E8*F7) | =MyUDF(T,A,B) | =(T7*B8 - T8*B7)/(A7*B8 - A8*B2) |
8 | 1 | 16.61 | 3 | 3 | 3.87 | =(D8*F4-D4*F8)/(E8*F4-E4*F8) | =MyUDF(T,A,B) | =(T8*B4 - T4*B8)/(A8*B4 - A4*B8) |
<tbody>
</tbody>
Column I shows the UDF call I would like to be able to make. Column J shows the original equation that I am trying to implement. I would like the code in the UDF to look as much like that equation as possible.
If I could make the code in the sheet look like that equation, I probably wouldn't need the UDF.
Note that the results are added from the bottom up. New results are added at the top.
Thanks for any help...