I am trying to incorporate a COUNTIFS formula into a worksheet via VBA - the formula I have works fine but it is not dynamic and with my rather limited VBA skills I've hit a bit of a brick wall.
To explain, the COUNTIFS look at 19 different headings (from H1 through to AA1) in the COMPILED worksheet, and count the occurence of "Yes"'s within a range in the TPR worksheet - it is this range that needs to be dynamic.
This is the VBA formula I am currently using, which works fine but, as mentioned, is a fixed range:
'Add in COUNTIFS formulas
With Sheets("COMPILED")
.Range("H2:AA" & .Cells(.Rows.Count, "A").End(xlUp).Row).FormulaR1C1 = "=IF(COUNTIFS(TPR!R5C2:R20000C2,COMPILED!RC1,TPR!R5C1:R20000C1,COMPILED!R1C)>0,""Yes"","""")"
End With
Many thanks and kindest regards, TE