ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   UDF Works in Debug Window but not on Sheet? (https://www.excelbanter.com/excel-programming/373709-udf-works-debug-window-but-not-sheet.html)

Andibevan

UDF Works in Debug Window but not on Sheet?
 
I have the following UDF which works when I call it from the debug window
but not on a sheet.

Any ideas?

Public Function GetRole(sRole As String) As Long

Debug.Print "GetRole = " & GetRole

GetRole = Sheets("Settings").Range("stng_Users").Find(sRole) .Row

Debug.Print "GetRole = " & GetRole

End Function



Bob Phillips

UDF Works in Debug Window but not on Sheet?
 
Find doesn't work in a UDF in Excel 2000 or earlier. It would work in debug
because that is not a UDF, it is VBA.

--
HTH

Bob Phillips

(replace somewhere in email address with gmail if mailing direct)

"Andibevan" wrote in message
...
I have the following UDF which works when I call it from the debug window
but not on a sheet.

Any ideas?

Public Function GetRole(sRole As String) As Long

Debug.Print "GetRole = " & GetRole

GetRole = Sheets("Settings").Range("stng_Users").Find(sRole) .Row

Debug.Print "GetRole = " & GetRole

End Function





Andibevan

UDF Works in Debug Window but not on Sheet?
 
Thanks Bob - would never have thought of that.




All times are GMT +1. The time now is 02:29 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com