JenniferMurphy
Well-known Member
- Joined
- Jul 23, 2011
- Messages
- 2,525
- Office Version
- 365
- Platform
- Windows
I have a little UDF that will convert a column number into a column letter:
The UDF is in one of my personal addins.
If I call this UDF from a worksheet, it works perfectly. But if I call it from another UDF that is called from that same worksheet, I get "Compile error: Sub or Function not defined".
What am I doing wrong?
Code:
Public Function CvtColNum2Ltr(ByVal ColNum As Integer) As String
Const MaxCol As Long = 16384 'Numerical value of maximum column (XFD).
If ColNum > MaxCol Then 'If column number if too large,
CvtColNum2Ltr = CVErr(xlErrValue) 'Return a value error
Exit Function
End If
CvtColNum2Ltr = Split(Cells(1, ColNum).Address, "$")(1)
End Function
If I call this UDF from a worksheet, it works perfectly. But if I call it from another UDF that is called from that same worksheet, I get "Compile error: Sub or Function not defined".
What am I doing wrong?