I am trying to count dynamic in a table using the header (see the picture below).
The problem is that i dont know how to make Tabelle14[[#Headers],[Cinema]] dynamic. I tried it with R[-1]C[0] but this is not the solution.
Is where any way to do it without a loop or do you have a better idea how to solve it?
At the moment i am doing this with .FormulaR1C1
Here is my Code
Sub countit()
Dim i As Integer: i = 2
Dim n_col As Integer
Dim tbl As ListObject
Set tbl = ActiveSheet.ListObjects("Tabelle14")
n_col = tbl.HeaderRowRange.Columns.Count - 1
Do While i < n_col
ActiveSheet.ListObjects("Tabelle14").ListColumns(i - 1).DataBodyRange(1, i).Select
ActiveCell.FormulaR1C1 = "=COUNTIFS(Tabelle13[Date],[@Date],Tabelle13[Name],Tabelle14[[#Headers],[Cinema]])"
i = i + 1
Loop
