View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
AltaEgo AltaEgo is offline
external usenet poster
 
Posts: 245
Default Counting exception number and pop up in MSG BOX

This should do it for you - I'll leave you fine-tune the wording in the
message box.

Sub CountResults()

Dim ResultF
Dim ResultOK
Dim ResultNA

ResultF = WorksheetFunction.CountIf(Range("yourRange"), "Fail")
ResultOK = WorksheetFunction.CountIf(Range("yourRange"), "OK")
ResultNA = WorksheetFunction.CountIf(Range("yourRange"), "#N/A")


MsgBox ResultNA & " Exceptions" & vbCrLf & ResultF & " Fail" & vbCrLf &
ResultOK & " OK"


End Sub


--
Steve

"Elton Law" wrote in message
...
Dear Expert,
Have run a marco and the final outcome is as follows:

Marks OK/Fail
10 Fail
9 Fail
19 OK
27 OK
21 OK
0 Fail
#N/A #N/A

Is it possible add certain VB scripts at the end of my existing marco so
that it can pop up a MSGBOX saying "there is 1 exception (becasue there is
one invalid data) and there are 3 Fails (beacasue there are 3 Fails)"
please ?
Thanks,
Elton