title: Finding Average and Standard Deviation on displayed, filtered data in Excel Using VBA
body: <p>So I am running into a small problem with my current code. My objective is to filter data in an excel sheet and take the average and standard deviation of that filtered data. Without filtering the data I can display the average and standard deviation. I get values for both the average and standard deviation. However, after I filter the data, I run the macro again, but it is displaying the same average and standard deviation as it did before when the data was not filtered. I was wondering what is wrong with my code or how can I tweak it so it takes the average and standard deviation only on the displayed data. </p>
  
  <p>Here is my code:</p>
  
  <p>'Code for average</p>
  
  <pre><code> Sub Avg()
   Range("F1").Value = Application.WorksheetFunction.Average(Columns("D"))
   End Sub
  </code></pre>
  
  <p>'Code for Std. Dev_S</p>
  
  <pre><code>Sub Dev()
  Range("G1").Value = (Application.WorksheetFunction.StDev_S(Columns("D"))) / 1.128
  End Sub
  </code></pre>