I have a table in a spreadsheet that I refresh daily. The number of rows in the worksheet changes from day to day and the formulas that I currently have in place to count up the items in the table do not include any new rows of data (if any) that are added to my table after a refresh.
I wanted to create a macro that would automatically update these formulas to include all rows in the table. The code below is my attempt. The code works just fine in terms of calculating the correct values, but it is not entering a formula into the cell. It is only entering in the result of the formula.
How can I change the code to enter the formula into the cell and not just the value?
Sub formula_update()
ThisWorkbook.Activate
Worksheets("Summary").Activate
Range("F9").Select
Do Until IsEmpty(Selection)
ActiveCell.Formula = Application.CountIfs(Range(ActiveCell.Offset(3, 0), ActiveCell.Offset(3, 0).End(xlDown)), "<>0")
ActiveCell.Offset(0, 1).Select
Loop
End Sub