jb
Member
>>> You've noted many times <<<
>>> use code - tags <<<
>>> use code - tags <<<
Code:
Set ws = ActiveWorkbook.Sheets("Consolidated")
lastrow = ws.Cells(Rows.Count, 1).End(xlUp).Row
Set rng = Range("n6:n65")
For i = 6 To lastrow
If Cells(i, 4) <> "" Then
startdate = Cells(i, 7)
endDate = Cells(i, 8)
Cells(i, 10).Value = Application.WorksheetFunction.CountIfs(rng, ">=" & startdate, rng, "<=" & endDate)
End If
Next i
Above is partly vba code where I have used countifs with date columns.
List of dates are available in in n6 to n65. (May not be all the cells in this range will have dates. But dates will start from n6 cell)
Column g (column no. 7) has start date. Column h (column no. 8) has end date.
There will be multiple rows having different value of start and end date. Data starts from row number 6. Date format is dd-mm-yyyy.
Now I want to calculate number of dates available in n2:n65 which fall between start date and end date in each row.
I want this calculated number in column number 10 (column j).
When I run this macro, it calculates 0. It is not giving any error. Where I am wrong in formula?
Last edited by a moderator: