VBA custom Function variable base on offset. HELP

popesku

New Member
Joined
Dec 27, 2015
Messages
11
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.





r/cABC
1RESULTDATA1DATA2
2=MYFUNCTION($A$1:$A$5)52
3
4
5

<tbody>
</tbody>
sheet one



r/cABCDE
11052
220154
330256
440358
5504510

<tbody>
</tbody>
sheet two

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 !
 

Excel Facts

Remove leading & trailing spaces
Save as CSV to remove all leading and trailing spaces. It is faster than using TRIM().

Forum statistics

Threads
1,214,979
Messages
6,122,561
Members
449,089
Latest member
Motoracer88

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top