ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   UDF behaving oddly (https://www.excelbanter.com/excel-programming/415170-udf-behaving-oddly.html)

PBcorn

UDF behaving oddly
 
The following UDF generates VALUE! errors intermittently and I can't figure
out why. The range argument references another (shared) workbook. It seems
that when this shared workbook is open the function works, when it is not
open, the error is generated. Can this be corrected?

Thanks



Public Function DTD(TIME As Range, CONVTYPE As Integer)

Select Case CONVTYPE

Case Is = 1
minutes = Int(TIME)
seconds = Round((TIME - minutes) * 60, 0)
DTD = TimeSerial(0, minutes, seconds)
Case Is = 2
minutes = Int(TIME)
seconds = (TIME - minutes) / 0.6
DTD = minutes + seconds

End Select

End Function


All times are GMT +1. The time now is 06:31 AM.

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