I have this code and idea is clear to apply formula till the last row and last column, i am not sure as what is wrong with this code.
the range of columns and rows are dynamic
VBA Code:
Sub Countdata()
Dim dERow As Double
Dim lECol As Long
dERow = Cells(10000, 4).End(xlUp).Row
lECol = Cells(10000, 5).End(xlUp).Row
Cells(4, 5).Formula = "=COUNTIFS('Actual DailyData'!$B:$B,$D4,'Actual DailyData'!$A:$A,E$3)"
Cells(4, 5).AutoFill Destination:=Range(Cells(4, 5), Cells(4, 5 + lECol - 2)) '- 1))
Range(Cells(4, 5), Cells(4, 5 + lECol - 2)).AutoFill Destination:=Range(Cells(5, 5), Cells(dERow, 5 + lECol - 2))
End Sub
the range of columns and rows are dynamic
Date | Emp1 | Emp2 |
09-02-2022 | 6 | 8 |
13-02-2022 | ||
13-02-2022 |