Home |
Search |
Today's Posts |
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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!! |
#2
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
None of the functions should work except the "to do" and "pass" versions
because of this example line: If Trim(LCase(TR.Cells(i, 1))) = "Fail" Then You are coercing the contents of TR.Cells(i, 1) to ALL lower case and then compare it to a word that has an upper case ("F" in this case). Change your comparison expressions to all lower case ("fail", "warning", "design" etc.) Regards, 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!! |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
ISBLANK function not working when cell is blank dut to function re | Excel Discussion (Misc queries) | |||
Working Days function copied down column | Excel Discussion (Misc queries) | |||
IF function not working | Excel Discussion (Misc queries) | |||
Problem using newly created user function in Excel 2003 | Excel Discussion (Misc queries) | |||
Working with Arrays, pasing from function to function | Excel Programming |