Hi. I have a test log with PASS/FAIL. These results are logged in Excel under the column heading PASS/FAIL.
How do I count the number of PASS or FAIL using VBA macro?
So far I have tried:
Sub PASS_FAIL_COUNT()
Dim count As Integer
Dim name As String
count = 0
Do
count = count + 1
name = Range("PASS/FAIL").Select
Loop Until (name <> "PASS" Or name <> "FAIL")
End Sub
This one did not work either:
Sub PASS_FAIL_COUNT()
Dim r As Range
Dim cell_count As Integer
Dim name As String
cell_count = 0
Do
Set r = Range("PASS/FAIL").Select
name = r.Cells(1, r.Columns.count).Select
If (name = "PASS" Or name = "FAIL") Then
cell_count = cell_count + 1
End If
Loop Until (name <> "PASS" Or name <> "FAIL")
End Sub
the error is at the name = Range("PASS/FAIL").Select line.
My thought process: once I had selected a range, I can now freely "look" at each string in a cell in that range. Not correct I guess.
Please advice. thank you.
p.s. all this is currently done in the active sheet.
Bookmarks