I am trying to insert and change a counta formula based on the iteration of the for loop. The problem I am facing is that even though the code runs without error, nothing happens. The totalrow variable is consistently 0. I'm not sure where I am going wrong here. All the variable have been initialized outside the loop. CurrentColname is string, countUsedCols is long, totalRows is long.

```
For i = 2 To countUsedCols
    ActiveSheet.Cells(3, i).Select
    currentColName = ActiveSheet.Cells(3, i).Value
    If currentColName = "Valid From" Then

        totalrow = ActiveWorkbook.Sheets("Customer_Facing_View").Range("AR1").Formula = "=COUNTA($" & i & ":$" & i & ")"

        totalrow = ActiveWorkbook.Sheets("Customer_Facing_View").Range("AR1").Value

```