title: How to copy/paste formula in filtered/visible cells via VBA in Excel
body: <p>I am struggling with copying and pasting formula from one column to another one within using filter in another column.</p>
  
  <p>I got a table with 52 columns (number of rows is changing each month).
  In column AW (#49) I have applied filter. It shows only <code>CTD</code>.
  After applying this filter I need to copy formula from column AH to column AG. Of course I need to apply this only for filtered/visible cells.
  The code I have written is copying/pasting this formula into all cells in column AG (it doesn't consider my filter in column AW).
  Another problem is that when applying the filter in column AW then the first visible row doesn't need to be all the time AH2 but it can be e.g. AH15 or whatever. I guess this could be avoid via some dynamic solution. Unfortunately I have no clue how to do it.</p>
  
  <p>Afterwards I would like to apply the same for filters in another columns.</p>
  
  <p>Many warm thanks in advance for any hint! :)</p>
  
  <p>This is my code:</p>
  
  <pre><code>Sub ApplyFilterInColumnAW()
  
  Sheets("DATA").Select
  ActiveSheet.ListObjects("tb_DATA").Range.AutoFilter Field:=49, Criteria1:="CTD"
  Range("AG2").Select  'dynamic solution?
  ActiveCell.FormulaR1C1 = "=[@[Service/Log Formula]]" 'header name of column AH
  
  End Sub
  </code></pre>