Google-sheets – How to pass a range on another sheet within the spreadsheet file to a custom function

google sheetsgoogle-apps-script

I know how to pass simple ranges to a custom function (ranges in the same sheet as the function usage). How can I pass the address of a cell in a different sheet to that function. For example
A1 has =myfcn(othersheet,row(a1),column(a1))

and function myfunction(sheetname, rownum,colnum, cells)

I only need to pass the address of one cell of the other sheet.

Best Answer

Assuming that the ANOTHER sheet name is Sheet2 and the cell that you want to refer is A2 then the reference to be used should be Sheet2!A2, then the resulting formula is

=myfcn(Sheet2!A2,row(a1),column(a1))