Thread: Counting Errors
View Single Post
  #5   Report Post  
Posted to microsoft.public.excel.programming
Jacob Skaria Jacob Skaria is offline
external usenet poster
 
Posts: 8,520
Default Counting Errors

Try the below macro,.....

Sub Macro()
For Each cell In Application.InputBox("Select", , , , , , , 8)
On Error Resume Next
Set sh = Sheets(CStr(cell.Text))
If sh Is Nothing Then intCount = intCount + 1
Next
End Sub



''The best way is to use a function such as below to check whether the sheet
exists or not and then to count it

Function SheetExists(strSheet As String) As Boolean
Dim sh As Worksheet
On Error Resume Next
Set sh = Sheets(strSheet)
If Not sh Is Nothing Then SheetExists = True
End Function

If this post helps click Yes
---------------
Jacob Skaria


"Faraz A. Qureshi" wrote:

No Jacob this is a totally different question pertaining as to how to count
errors in a loop like:

For Each cell In Application.InputBox("Select", , , , , , , 8)
If a cell is not containing sheet name add to counter
End if
Carry on
... Next

--
Best Regards,

Faraz


"Jacob Skaria" wrote:

Do you mean

Sub Macro()
strFormula = "=SUM(IF(A1:A10<"""",IF(ISNA(MATCH(A1:A10,B1:B20, 0)),1,0)))"
MsgBox Application.Evaluate(strFormula)
End Sub

If this post helps click Yes
---------------
Jacob Skaria


"Faraz A. Qureshi" wrote:

Kindly clarify with an example like finding how many of cells in A1:A10 do
not reflect the names of sheets present in a workbook?

Best Regards,

Faraz