View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.misc
Tom Hutchins Tom Hutchins is offline
external usenet poster
 
Posts: 1,069
Default Count entry only once across multiple worksheets?

Here is one way...

Sub AAAAA()
MsgBox CountShtFind("other", "H9:H32")
End Sub

Public Function CountShtFind(MyStr As String, MyRng As String) As Long
Dim ws As Worksheet, ans
CountShtFind = 0
For Each ws In ActiveWorkbook.Sheets
'search MyRng for MyStr
Set ans = ws.Range(MyRng).Find(What:=MyStr, LookIn:=xlValues, _
LookAt:=xlPart, SearchOrder:=xlByRows, SearchDirection:=xlNext, _
MatchCase:=False, SearchFormat:=False)
'returns Nothing if not found
If Not ans Is Nothing Then
CountShtFind = CountShtFind + 1
End If
Next ws
End Function

Paste the code in a VBA module in your workbook. Run it from your worksheet
by selecting Tools Macro Macros AAAAA Run.

If you are new to macros, this link to Jon Peltier's site may be helpful:
http://peltiertech.com/WordPress/200...e-elses-macro/

Hope this helps,

Hutch

"tgcali" wrote:

Hello,

How can I count each worksheet a criteria appears on in a range of cells?
Not the number of times it appears total, but the number of sheets it appears
on.

For example:

The range is H9:H32, the entry I'm needing to count is "other" and there are
250 sheets. I don't want the total number of times the word "other" appears,
but the total number of sheets it appears on in that range. Make sense?

Thank you very much in advance. Any assistance would be greatly appreciated.

tgcali