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
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
Thanks that works just great, I can see what I really need now, to
just count all the "hello" in the same column "n" in each worksheet
with the workbook.
Thanks that works just great, I can see what I really need now, to
just count all the "hello" in the same column "n" in each worksheet
with the workbook.
Option Explicit
Sub countjune()
Dim ws As Worksheet
Dim mycol As Range
Dim mc As Long
For Each ws In Worksheets
Set mycol = ws.Columns("N")
mc = mc + Application.CountIf(mycol, "Hello")
Next ws
MsgBox mc
End Sub
Ask a Question
Want to reply to this thread or ask your own question?
You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.