Hi there,
I am trying to come up with a VB solution that counts records based on conditions in VB. I have attached the file.
In "Quarterly reports ALL" sheet, you see a table and ONLY B3 to Q19 need values to be populated by VB.
The "IC collection" is where data gets collected.
The following code is countifs using VB, but it's not quite working.
n is the row counter on the report page while r is the column counter on the report page.
Private Sub CommandButton1_Click()
Dim n As Long
Dim r As Long
lastRowData = Worksheets("IC Data Collection").UsedRange.Rows.Count
For n = 4 To 20
For r = 2 To 16
Worksheets("Quarter Reports ALL").Cells(n, r) = Application.WorksheetFunction.CountIfs(Worksheets("IC Data Collection").Range("H"), Worksheets("Quarterly Reports ALL").Cells(n, 1), Worksheets("IC Data Collection").Range("E"), Worksheets("Quarterly Reports ALL").Cells(3, r))
Next r
Next n
End
End Sub
When I run the code, I get the application-defined error. I must have got the range target wrong or some sort of syntax error, but I'm not sure.
Anyone able to assist?
Thanks
Bookmarks