View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
James Ravenswood James Ravenswood is offline
external usenet poster
 
Posts: 143
Default countif - in an entire workbook

On Sep 25, 4:33*pm, Johnnyboy5 wrote:
Hi *I need some kind formula to Countif (all the cells in whole
workbook / worksheet) for a certain text string.

johnnboy


This will count all the cells in all the worksheets containing "hello"

Sub SuperCount()
Dim r As Range
SuperCounter = 0
s = "hello"
For Each sh In Sheets
sh.Activate
For Each r In ActiveSheet.UsedRange
If r.Value = s Then
SuperCounter = SuperCounter + 1
End If
Next
Next
MsgBox SuperCounter
End Sub