I have what I think is a relatively simple function I'm running where I'm basically trying to find how much time someone stays waiting in the queue for a call back. It runs great when I'm in the VBA tab, but when I call the function in my spreadsheet I get a #REF! error.
    Function TIQ2()
    Dim time, count, i As Integer
    Dim TIQ
    time = 0
    count = 0
    NumRows = Sheet1.Range("A2", Sheet1.Range("A2").End(xlDown)).Rows.count + 1
    For i = 2 To NumRows
        If Sheet1.Range("c" & i) = "no" Or Sheet1.Range("c" & i) = "No" Then
    
            If Sheet1.Range("d" & i) = "No" Or Sheet1.Range("d" & i) = "no" Then
            time = time + Left(Sheet1.Range("g" & i), 2)
            count = count + 1
            Debug.Print time, count
        End If
    End If
  Next
  TIQ2 = WorksheetFunction.RoundUp(time / count, 0) & " minutes"
  Debug.Print TIQ2
End Function
 
     
     
    