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
Since you asked and to help others, here's the code
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