I have a problem that im sure theres a simple solution to.
I have a range of cells (D1:D20) that get a formula entered into through VBA depending on the value of another cell (A1). The forumla that gets inputted looks like this:

=myfunction(A1)
Problem is when my code determines D1:d20 need this formula entered into them, it puts 'myfunction(a1) in D1, my function(A2) in D2, myfunction(a3) in D3, etc, etc). Excel automatically keeps on incrementing the cell # im referencing. This isnt what I want. I always need A1 to be the cell referenced.
Is there a way I can tell excel not to do this? Keep in mind I am not entering the formula in manually, but do so through a snippet of code like this:

If Target.Address = "$A$1" Then
If Target.Value <> "Stuff" Then
Range("D1:D20").Formula = "=myfunction(A1)"