JenniferMurphy
Well-known Member
- Joined
- Jul 23, 2011
- Messages
- 2,702
- Office Version
- 365
- Platform
- Windows
I have a UDF that is called from just one cell (D20) in just one sheet (Sheet1) in just one workbook (Book1). But if I change the contents of any cell in that sheet, or any other sheet in that workbook, or even any cell in any sheet in any open workbook, the UDF gets called. And it always gets called from Book1.Sheet1.$D$20. I know this because I am tracking the caller info using the code below.
I ended up adding the code above to exit the function if it wasn't called from the right sheet.
I had been fooling around with making this UDF volatile. When it was, then this behavior would occur, but then it was expected -- at least in the same workbook. But as you can see, I have commented out the Application.Volatile statement. I also did a search for "volatile" in that project and found none. I also did a search for any calls to that UDF in the workbook. None were found.
What the heck is going on here and how do I cure it?
Thanks
Code:
Public Function WtdRtg(Optional p1 As String) As Variant
'Application.Volatile
Dim CallerBookName As String 'Name of calling workbook
Dim CallerSheetName As String 'Name of calling worksheet
Dim CallerCellAddr As String 'Address of calling cell
CallerBookName = Application.Caller.Worksheet.Parent.Name
CallerSheetName = Application.Caller.Worksheet.Name
CallerCellAddr = Application.Caller.Address
If p1 <> CallerSheetName Then Exit Function
I ended up adding the code above to exit the function if it wasn't called from the right sheet.
I had been fooling around with making this UDF volatile. When it was, then this behavior would occur, but then it was expected -- at least in the same workbook. But as you can see, I have commented out the Application.Volatile statement. I also did a search for "volatile" in that project and found none. I also did a search for any calls to that UDF in the workbook. None were found.
What the heck is going on here and how do I cure it?
Thanks