I'm doing a script where i can count the data from a column if the data duplicate is >3 i will tag it..
My problem is that i need to put a conditional statement where i can count the data within a date range of 1 Month..
Sample Input File:: (mm/dd/yyyy)
Column A | Column B | Column C| Column D
023 | 1/2/2016 | |
023 | 1/3/2016 | |
023 | 1/4/2016 | |
024 | 2/1/2016 | |
024 | 3/1/2016 | |
024 | 4/1/2016 | |
Sample Output File:
Column A | Column B | Column C| Column D
023 | 1/2/2016 | |
023 | 1/3/2016 | |
023 | 1/4/2016 | 1 | 3
024 | 2/1/2016 | |
024 | 3/1/2016 | |
024 | 4/1/2016 | |
If the duplicate data is not within a month range it will not be tag..
What i expect the code to do is count the data from Column A if the data is >3 and the date of all that data from Column B is within a month tag it from Column D and E not all the row but the recent date from Column B
What my code do is count the data from Column A if the data is >3 it will be tag from Column C and D from most recent date from Column B
My code:
Dim i1 As Long, lastRow As Long, countRow As Long
lastRow = Sheet2.Range("T" & Rows.Count).End(xlUp).Row
'xDate = Sheet2.Range("C" & lastRow)
For i1 = 1 To lastRow
If countRow > 2 Then
countRow = Application.CountIf(Sheet2.Columns(20), Sheet2.Cells(i1, 20))
If countRow > 2 Then
If Not CBool(Application.CountIfs(Sheet2.Columns(20), Sheet2.Cells(i1, 20), _
Sheet2.Columns(85), ">" & Sheet2.Cells(i1, 85))) Then _
Sheet2.Cells(i1, 86).Resize(1, 2) = Array("1", "3")
End If
End If
Next i1
Note:
- In my code i didn't use
ColumnABCDinstead it'sColumnTCGCHCI
I don't know how to range it to a month, i tried collection but still new to VBA and I'm not familiar with it and i don't know if it's the right thing..

