網路上的範例:
Function Sheetname()
Application.Volatile
Sheetname = Application.Caller.Parent.Name
End Function
Function Test()
Application.Volatile
' Returns the cell one column to the left of the active cell. Note
' that the active cell is not necessarily the cell that is calling
' the function.
Test = ActiveCell.Offset(0, -1).Value
End Function
change it to the following:
Function Test()
Application.Volatile
' Returns the cell one column to the left of the cell that is
' actually calling the function.
Test = Application.Caller.Offset(0, -1).Value
End Function