Firstly, you "should" refer to the formula in a cell by .Cells(i,j).Formula
You'll possibly get away without it, but you should be explicit in case
Excel has trouble deciding what you mean.
Secondly, your string to the right of the equals has quotes within the
quotes. If you want quotes as literals in a string you need to put two of
them at each place.
Thirdly, I think you'll find that #REF is fully in capitals.
But, most importantly, you are putting into the cell (or trying to) the
formula =Replace("#Ref",1, 10, "Autofilter"). You are not replacing the
formula with a minor variation, you are replacing it with a replace
statement.
My statement that does it - for A1 only - is
Cells(1, 1).Formula = Replace(Cells(1, 1).Formula, "#REF", "Autofilter")
You'd need to change the 1,1 back and put the dot before both of the Cells
calls, but that's pretty much what you'd want.