How can I create a function in VBA so that I can pass a cell range as an argument?
For example, I want to call the function in the spreadsheet in a random cell by writing
=function_name(A2:A7)
My code gives me a ?NAME# error when I call it in the spreadsheet.
Public Function xyz ( ByRef x() As Variant, sizeOfSelection As Integer )
xyz=x(0);
End Function
It is coded in a Module and my Macros is on.