Search an array of sheets for an array of numbers & return countof numbers
Sub WSnNumCount3()
Dim vNumsToCount, vShtsToSearch
Dim rng As Range, n&, j&, k&
With Sheets("Sheet1")
vNumsToCount = .Range("A2:B10")
vShtsToSearch = .Range("C2:C6")
End With
For n = LBound(vNumsToCount) To UBound(vNumsToCount)
For k = LBound(vShtsToSearch) To UBound(vShtsToSearch)
Set rng = Sheets(vShtsToSearch(k, 1)).UsedRange
j = j + WorksheetFunction.CountIf(rng, vNumsToCount(n, 1))
Next 'k
vNumsToCount(n, 2) = j: j = 0
Next 'n
' Range("A2:B10") = vNumsToCount
Sheets("Sheet1").Range("B2").Resize(UBound(vNumsTo Count), 1) _
= Application.Index(vNumsToCount, 0, 2)
End Sub
--
Garry
So 1st row, 2nd col is arr(1,2)!
Okay, I think I see what you are saying.
Seemed like that example was from a pretty good source, but I may well have misconstrued it.
The last code is very nice, I like the 0's (Zeros) if no number if found.
Thanks.
Howard
|