hello
I want to write a custom function. And i dont know hot to offset some variables.
MYFUNCTION ("somerange")
Lets presume i have two sheets.
In the first sheet i have the sheet i am working with the formula, and in the other one i have the data.
In my custom formula it will be 5 variables base on a single range
ok i dont really know vba very well , and i want to undestand the steps.
<tbody>
</tbody>sheet one
<tbody>
</tbody> sheet two
Question one. How to write with VBA that array2/array3 is offset with +2/+4 columns from the selectect range.
Question two. If that can be done how i say to VBA to lock the row and column from array2/array3 selection (it will be for a INDEX)
result expected base on the offset array2($C$1:$C$5) , array3($E$1:$E$5)
Question three. How to write with VBA that in the sheet were the function is writed (in this case sheet one). there are two variables data1/data2 on the same row, offset to the cell +1/+2 were the function is writed. Locked with a single dollar.
result expected based on the offset data1($B2), data2($C2)
Thank you !
I want to write a custom function. And i dont know hot to offset some variables.
MYFUNCTION ("somerange")
Lets presume i have two sheets.
In the first sheet i have the sheet i am working with the formula, and in the other one i have the data.
In my custom formula it will be 5 variables base on a single range
ok i dont really know vba very well , and i want to undestand the steps.
r/c | A | B | C |
1 | RESULT | DATA1 | DATA2 |
2 | =MYFUNCTION($A$1:$A$5) | 5 | 2 |
3 | |||
4 | |||
5 |
<tbody>
</tbody>
r/c | A | B | C | D | E |
1 | 10 | 5 | 2 | ||
2 | 20 | 15 | 4 | ||
3 | 30 | 25 | 6 | ||
4 | 40 | 35 | 8 | ||
5 | 50 | 45 | 10 |
<tbody>
</tbody>
Code:
Function Myfunction(pieces)
Dim array2
Dim array3
Dim data1
Dim data2
End Function
Question one. How to write with VBA that array2/array3 is offset with +2/+4 columns from the selectect range.
Question two. If that can be done how i say to VBA to lock the row and column from array2/array3 selection (it will be for a INDEX)
result expected base on the offset array2($C$1:$C$5) , array3($E$1:$E$5)
Question three. How to write with VBA that in the sheet were the function is writed (in this case sheet one). there are two variables data1/data2 on the same row, offset to the cell +1/+2 were the function is writed. Locked with a single dollar.
result expected based on the offset data1($B2), data2($C2)
Thank you !