LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #10   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 8,520
Default Counting Errors

Have you gone through the previous posts..Try the below..

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

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


"Faraz A. Qureshi" wrote:

Sorry Jacob but the code:

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

doesn't seem to be presenting correct number of errors. It seems to be
missing sometimes the blank cells.
--
Best Regards,

Faraz


"Jacob Skaria" wrote:

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



 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Counting errors kittronald Excel Worksheet Functions 5 May 19th 11 11:45 PM
Counting with a condition disregarding errors vsoler Excel Worksheet Functions 7 May 19th 07 10:04 PM
VBA counting colors, errors TheRook Excel Programming 1 August 18th 06 06:04 PM
VBA counting colors, errors Ken Johnson Excel Programming 0 August 18th 06 12:56 PM
Counting Errors Tarique Excel Worksheet Functions 1 February 24th 06 04:54 PM


All times are GMT +1. The time now is 02:08 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"