ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Copied function is not working (https://www.excelbanter.com/excel-programming/381239-re-copied-function-not-working.html)

Greg Wilson

Copied function is not working
 
See my response to your other post.

Greg

"CJ" wrote:

In my spreadsheet, I have a module where the following working functions
previously existed:

Function GetPass(TR As Range) As Integer
Dim i As Integer, c As Integer
For i = 1 To TR.Count
If Trim(LCase(TR.Cells(i, 1))) = "pass" Then
c = c + 1
End If
Next i
GetPass = c
End Function
-----------------------------------------------
Function GetFail(TR As Range) As Integer
Dim i As Integer, c As Integer
For i = 1 To TR.Count
If Trim(LCase(TR.Cells(i, 1))) = "Fail" Then
c = c + 1
End If
Next i
GetFail = c
End Function
-----------------------------------------------
Function GetToDo(TR As Range) As Integer
Dim i As Integer, c As Integer, d As String
For i = 1 To TR.Count
If Trim(LCase(TR.Cells(i, 1))) = "to do" Then
c = c + 1
End If
Next i
GetToDo = c
End Function
-----------------------------------------------
Function GetTotal(TR As Range) As Integer
GetTotal = TR.Count
End Function

**********
I needed to further define a "fail" status so I renamed fail to bug in the
above function. Then I copied that function and defined it for each of my
other fail types. (Blocked, Warning, Design) - see below:

Function GetBlocked(TR As Range) As Integer
Dim i As Integer, c As Integer, d As String
For i = 1 To TR.Count
If Trim(LCase(TR.Cells(i, 1))) = "Blocked" Then
c = c + 1
End If
Next i
GetBlocked = c
End Function
-----------------------------------------------
Function GetWarning(TR As Range) As Integer
Dim i As Integer, c As Integer, d As String
For i = 1 To TR.Count
If Trim(LCase(TR.Cells(i, 1))) = "Warning" Then
c = c + 1
End If
Next i
GetWarning = c
End Function
-----------------------------------------------
Function GetDesign(TR As Range) As Integer
Dim i As Integer, c As Integer
For i = 1 To TR.Count
If Trim(LCase(TR.Cells(i, 1))) = "Design" Then
c = c + 1
End If
Next i
GetDesign = c
End Function
*******************

In my spreadsheet I have a variable called OTStatus that defines a range of
cells. Then at the top of my spreadsheet I have a call that tallies the
occurence of each of the statuses (Pass, Bug, To Do, Design, Blocked, etc).
This formula is GetPass(OTStatus).
The issue that I'm having is that the functions I copied and modified are
not working in my spreadsheet. For instance in my range (OTStatus) I have
one occurence of Bug, however the cell that is defined with formula:
GetBug(OTStatus), it shows a count of 0. Copying the code for the function
does not appear to be working.

I would be ever so grateful if someone could help. I'd gladly send you my
spreadsheet to help show you what I'm trying to explain! :)

Thank you so kindly in advance!!





All times are GMT +1. The time now is 09:07 PM.

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