I have to write a macro for the following scenario:
I have a excel book having one sheet. Sheet contains the module name with test case and test status. I have to count the test case with the test status for a particular module say "Mod1".
Module Test Case ID Status
Mod1 123 Pass
Mod2 124 Fail
Mod1 125 Fail
Mod1 126 Blocked
Mod5 127 Pass
Mod1 128 NA
the code i have written is as below:
Sub testnw()
Dim k, l, ps, fl, bl, na As Integer
Dim frng As Range
ps = 0
fl = 0
bl = 0
na = 0
frng = Worksheets(1).Range("A1")
k = 1
l = 1
While (frng.Cells(k, l).Value <> "")
If frng.Cells(k, l).Value = "Mod1" Then
If frng.Cells(k, l + 2).Value = "Pass" Then
ps = ps + 1
ElseIf frnng.Cells(k, l + 2).Value = "Fail" Then
fl = fl + 1
ElseIf frng.Cells(k, l + 2).Value = "Blocked" Then
bl = bl + 1
Else
na = na + 1
End If
End If
Wend
MsgBox (ps)
MsgBox (fl)
MsgBox (bl)
MsgBox (na)
End Sub
on running the above code I am getting an error message is that "Object Variable or With Block variable not set".
Can anybody tell me where I am wrong and get me the correct code?
Thanks in advance.