excel1.png

I have 5 cols of data that I want to count occurrences in.

I have run a unique filter to list the ID's in a separate area.
Now I want to count occurrence for each column and ID using VBA.

I am attempting to use countif with the criteria being from a cells text.
If I run

Range("O" & i).Formula = "=countif(O15:O" & lastrow & ",n165)"

, it works fine, but I can't get it right to run with the cell as a reference.

Any help would be appreciated.