drpdrpdrp
New Member
- Joined
- Sep 9, 2021
- Messages
- 22
- Office Version
- 2019
- 2016
- Platform
- Windows
I understand that I can take a range of values and make a vectorized calculation on it by using {...} in plain excel (Method 2)
(Method 1) below is showing the simplest way of accomplishing what I need:
1. Take the values in a range/vector/array,
2. subtract a fixed value from each
3. save as a new vector/range/array
4. average the values in the new_vector, and return the single value result
How can I write a VBA UDF { MyFunction(range, val) } to use on G9 (Method3) ?
(Method 1) below is showing the simplest way of accomplishing what I need:
1. Take the values in a range/vector/array,
2. subtract a fixed value from each
3. save as a new vector/range/array
4. average the values in the new_vector, and return the single value result
How can I write a VBA UDF { MyFunction(range, val) } to use on G9 (Method3) ?
Book1 | ||||||||||
---|---|---|---|---|---|---|---|---|---|---|
A | B | C | D | E | F | G | H | |||
1 | rng | Method1 | Method2 | Method3 | ||||||
2 | 12 | val: | 10 | "manual" | "array" | VBA | ||||
3 | 23 | 2 | ||||||||
4 | 54 | 13 | ||||||||
5 | 65 | 44 | ||||||||
6 | 12 | 55 | ||||||||
7 | 345 | 2 | ||||||||
8 | 335 | |||||||||
9 | 75.2 | 75.2 | ??? | |||||||
10 | ||||||||||
Sheet1 |
Cell Formulas | ||
---|---|---|
Range | Formula | |
E3:E8 | E3 | =A2-$C$2 |
E9 | E9 | =AVERAGE(E3:E8) |
F9 | F9 | =AVERAGE($A$2:$A$7-$C$2) |
Press CTRL+SHIFT+ENTER to enter array formulas. |