If I had to describe my situation, I have a dataset with changing number of rows and columns from which I further use this data with pivot table. The problem is that I have to construct a new variable (named "children") every time I change this dataset and now I have to do it manually.

Concretely, this variable is computed through this formula (the example is for the second row): =COUNTIF(BJ2:BS2; "<=10"). And I want a result from this formula for every row of my dataset starting the second row (in the first row there are the names of variables).

But as I don't want to do this every time the dataset changes, manually, I think about using a macro that would know how many rows and how many columns there are and where to put the variable and for how many rows it has to be counted.

If you guys had any recommendation, I would be grateful.