My standard reply is "Don't do that!" Use one sheet, with a column for date. Then you can use pivot tables, filters, normal formulas etc.
If you are determined to continue with multple sheets (as you described your workbook structure), you could use a User-Defined-Function (a macro). Copy the code below into a standard codemodule, set a reference to MS scripting Runtime, and use the function like so:
=UniqueCount(A5:A154)
If you want a list of all the unique values, run the macro "GetUniques" When prompted, select A5:A154 on any sheet, and an anchor cell for output.
Function UniqueCount(rMN As Range) As Integer
Dim Sh As Worksheet
Dim Dict As Scripting.Dictionary
Dim i As Long
Set Dict = New Scripting.Dictionary
With Dict
For Each Sh In Worksheets
For i = 1 To Sh.Range(rMN.Address).Cells.Count
If Sh.Range(rMN.Address).Cells(i).Value <> "" Then
.Item(Sh.Range(rMN.Address).Cells(i).Value) = 1
End If
Next i
Next Sh
UniqueCount = .Count
End With
End Function
Sub GetUniques()
Dim rngV As Range
Dim rngO As Range
Set rngV = Application.InputBox("Select the range to check (on one sheet, not all)", Type:=8)
Set rngO = Application.InputBox("Select the anchor cell for output.", Type:=8)
UniqueValues rngV, rngO
End Sub
Sub UniqueValues(rMN As Range, rOut As Range)
Dim Sh As Worksheet
Dim Dict As Scripting.Dictionary
Dim i As Long
Set Dict = New Scripting.Dictionary
With Dict
For Each Sh In Worksheets
For i = 1 To Sh.Range(rMN.Address).Cells.Count
If Sh.Range(rMN.Address).Cells(i).Value <> "" Then
.Item(Sh.Range(rMN.Address).Cells(i).Value) = 1
End If
Next i
Next Sh
rOut.Resize(.Count, 1).Value = Application.Transpose(.Keys)
End With
End Sub
Bookmarks