PDA

View Full Version : Solved: Custom Function for UpTime Calculation



rajkumar
06-21-2009, 12:21 PM
Hi,

I have written a custom function for calculating Uptime of Printers.


Function UpTime(StartDate, EndDate, NoOfMcs, DownTime)
UpTime = (Networkdays(StartDate, EndDate) * 8.5) * NoOfMcs - DownTime / (Networkdays(StartDate, EndDate) * 8.5)
UpTime = Application.Round(UpTime, 2)
End Function


Here iam getting an error "Sub or Function not defined" and the Networkdays is higlighted with Yellow Color

Can anybody help me to sort out this Error.

I have attached a sample workbook herewith.

Thanks in advance

p45cal
06-21-2009, 03:04 PM
Difficult to tell, see if this:
http://www.bettersolutions.com/excel/EIK284/NO418618333.htm
helps.

Bob Phillips
06-21-2009, 03:13 PM
Function UpTime(StartDate, EndDate, NoOfMcs, DownTime)
Dim tmp

tmp = Application.Run("ATPVBAEN.XLA!Networkdays", StartDate, EndDate) * 8.5
UpTime = tmp * NoOfMcs - DownTime / tmp
UpTime = Application.Round(UpTime, 2)
End Function

rajkumar
06-21-2009, 06:08 PM
Thanks Xld,

I just added paranthesis at required places and it is working perfectly.


Function UpTime(StartDate, EndDate, NoOfMcs, DownTime)
Dim tmp
tmp = Application.Run("ATPVBAEN.XLA!Networkdays", StartDate, EndDate) * 8.5
UpTime = ((tmp * NoOfMcs) - DownTime) / tmp
UpTime = Application.Round(UpTime, 2)
End Function


One more small thing, How do i set the number format to percentage in the function? could you please help.

Raj

Bob Phillips
06-22-2009, 12:29 AM
Thanks Xld,

I just added paranthesis at required places and it is working perfectly.

I thought that might be the way it should work but I just copied your original code which didn't have them.


One more small thing, How do i set the number format to percentage in the function? could you please help.

You don't, you format the target cell in Excel.

rajkumar
06-22-2009, 02:53 AM
Thanks Xld,

I am doing it
Raj