Consulting

Results 1 to 6 of 6

Thread: Solved: Custom Function for UpTime Calculation

  1. #1

    Solved: Custom Function for UpTime Calculation

    Hi,

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

    [VBA]
    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
    [/VBA]

    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

  2. #2
    Knowledge Base Approver VBAX Wizard p45cal's Avatar
    Joined
    Oct 2005
    Location
    Surrey UK
    Posts
    5,876
    Difficult to tell, see if this:
    http://www.bettersolutions.com/excel...O418618333.htm
    helps.
    p45cal
    Everyone: If I've helped and you can't be bothered to acknowledge it, I can't be bothered to look at further posts from you.

  3. #3
    Distinguished Lord of VBAX VBAX Grand Master Bob Phillips's Avatar
    Joined
    Apr 2005
    Posts
    25,453
    Location
    [vba]

    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
    [/vba]
    ____________________________________________
    Nihil simul inventum est et perfectum

    Abusus non tollit usum

    Last night I dreamed of a small consolation enjoyed only by the blind: Nobody knows the trouble I've not seen!
    James Thurber

  4. #4

    Custom Function for UpTime Calculation

    Thanks Xld,

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

    [VBA]
    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
    [/VBA]

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

    Raj

  5. #5
    Distinguished Lord of VBAX VBAX Grand Master Bob Phillips's Avatar
    Joined
    Apr 2005
    Posts
    25,453
    Location
    Quote Originally Posted by rajkumar
    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.

    Quote Originally Posted by rajkumar
    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.
    ____________________________________________
    Nihil simul inventum est et perfectum

    Abusus non tollit usum

    Last night I dreamed of a small consolation enjoyed only by the blind: Nobody knows the trouble I've not seen!
    James Thurber

  6. #6

    Custom Function for UpTime Calculation

    Thanks Xld,

    I am doing it
    Raj

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •