Auto-generate count of items in a column - Excel

xiaonajia

Senior Member
Joined
Mar 11, 2018
Messages
1,029
Reaction score
1
Column A|B|C|D|E|F|G

Fruit|Date|Countif| (blank) |Fruit|Date|Countif

I1 refers to the date to filter by.

Column C contains the countif formula

Code:
Private Sub Duplicate_Click()
On Error Resume Next
    If ActiveSheet.AutoFilterMode Then ActiveSheet.ShowAllData
On Error GoTo 0
ActiveSheet.Range("A1:C9999").Copy
'PasteSpecial Values Only
ActiveSheet.Range("E1:G9999").PasteSpecial Paste:=xlPasteValues
'Clear Clipboard (removes "marching ants" around your original data set)
Application.CutCopyMode = False
ActiveSheet.Range("F:F").NumberFormat = "dd-mmm-yy"

ActiveSheet.Sort.SortFields.Clear

ActiveSheet.Range("E1:G9999").AutoFilter Field:=1, Criteria1:="<>0"
ActiveSheet.Range("E1:G9999").AutoFilter Field:=2, Criteria1:=">=" & Range("I1")
ActiveSheet.Range("E1:G9999").Sort Key1:=Range("G1"), Key2:=Range("F1"), Header:=xlYes, _
    Order1:=xlDescending, Order2:=xlDescending
 
ActiveSheet.Range("E1:G9999").RemoveDuplicates Columns:=1, Header:=xlYes
 
End Sub

Since you asked and to help others, here's the code
 

davidktw

Arch-Supremacy Member
Joined
Apr 15, 2010
Messages
13,507
Reaction score
1,261
Column A|B|C|D|E|F|G

Fruit|Date|Countif| (blank) |Fruit|Date|Countif

I1 refers to the date to filter by.

Column C contains the countif formula

...

ActiveSheet.Range("E1:G9999").RemoveDuplicates Columns:=1, Header:=xlYes

End Sub

[/CODE]

Since you asked and to help others, here's the code
Fantastic. Of course when it is help I need, I asked. I only set challenge when I already have the answer. :)

Here are mine
FKNUn3G.png

RVzlYEs.png

GFAhVIO.png
 
Last edited:
Important Forum Advisory Note
This forum is moderated by volunteer moderators who will react only to members' feedback on posts. Moderators are not employees or representatives of HWZ Forums. Forum members and moderators are responsible for their own posts. Please refer to our Community Guidelines and Standards and Terms and Conditions for more information.
Top