Godders199
Active Member
- Joined
- Mar 2, 2017
- Messages
- 313
- Office Version
- 2013
Hello, I currently have the following code to calculate howmany entries there are for each employee with in the date range (daterng2 &daterng3).
I have now been asked to add an additional column which willbe cells(I,7) detailing how many unique months those entries fall under. Ie
01/01/2018
01/01/2018
01/03/2018
01/05/2018
01/05/2018
Should return the value 3.
Am I able to add to this code to calculate the number ofmonths? Or do I need to start again from scratch. Looking on google I can’t find any example ofVBA for this.
Dim lastrowcolumnA As Long
lastrowcolumnA = Range("a" &Rows.Count).End(xlUp).row
For i = 2 To lastrowcolumnA
Cells(i, 6) =WorksheetFunction.CountIfs(ThisWorkbook.Sheets("Adviserdata").Range("A:A"), Cells(i, 1), ThisWorkbook.Sheets("Adviserdata").Range("d:d"), ">=" & Daterng2,ThisWorkbook.Sheets("Adviser data").Range("d:d"),"<=" & Daterng3)
Thanks
I have now been asked to add an additional column which willbe cells(I,7) detailing how many unique months those entries fall under. Ie
01/01/2018
01/01/2018
01/03/2018
01/05/2018
01/05/2018
Should return the value 3.
Am I able to add to this code to calculate the number ofmonths? Or do I need to start again from scratch. Looking on google I can’t find any example ofVBA for this.
Dim lastrowcolumnA As Long
lastrowcolumnA = Range("a" &Rows.Count).End(xlUp).row
For i = 2 To lastrowcolumnA
Cells(i, 6) =WorksheetFunction.CountIfs(ThisWorkbook.Sheets("Adviserdata").Range("A:A"), Cells(i, 1), ThisWorkbook.Sheets("Adviserdata").Range("d:d"), ">=" & Daterng2,ThisWorkbook.Sheets("Adviser data").Range("d:d"),"<=" & Daterng3)
Thanks