Hi,
I wrote a short code to get a unique count of a column, and I'm trying to get it to write that value in a certain cell. However, the last statement in my code is not correct where it says ActiveRange.Value = MyUnique.Count.
What am I doing wrong?
Thanks!
I wrote a short code to get a unique count of a column, and I'm trying to get it to write that value in a certain cell. However, the last statement in my code is not correct where it says ActiveRange.Value = MyUnique.Count.
What am I doing wrong?
Code:
Sub SetupTest2()
'1. Select Pivot, Select B4, control+shift down, count filled rows, store count
Dim MyUnique As Object, c As Range
Set MyUnique = CreateObject("Scripting.Dictionary")
Sheets("Pivot").Select
Range("B4").Select
Range(Selection, Selection.End(xlDown)).Select
NumberofRows = Selection.Count
Sheets("Details").Select
Range("B3").Select
Range(Selection, Selection.End(xlDown)).Select
For Each c In Selection
If c.EntireRow.Hidden = False Then MyUnique(CStr(c)) = 1
Next c
With ActiveSheet
Range("B3").Select
Selection.End(xlDown).Select
Selection.Offset(2, 0).Select
ActiveRange.Value = MyUnique.Count
End With
End Sub
Thanks!