Home |
Search |
Today's Posts |
#10
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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 |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Counting errors | Excel Worksheet Functions | |||
Counting with a condition disregarding errors | Excel Worksheet Functions | |||
VBA counting colors, errors | Excel Programming | |||
VBA counting colors, errors | Excel Programming | |||
Counting Errors | Excel Worksheet Functions |