title: performing gradient calculations with LINEST 5000 times without manually inputting code
body: <p>I'm trying to perform gradient calculations on sets of force-distance curve data. I seem to have the calculation code for 100 sets of data (x,y) although continuing this manually to 5000 would take a lot of time. I was wondering if there was a function in which I could perform in order to pursue the calculations to 5000 sets of x,y data. is it a loop function? sorry for this but I'm a bio-physicist and new to coding.</p>
  
  <p>Below is some examples of my code:</p>
  
  <pre><code>  Sub S_Grad_Extraction()
  '
  ' S_Grad_Extraction Macro
  '
  
  '
      Sheets.Add After:=ActiveSheet
      ActiveCell.FormulaR1C1 = _
          "=LINEST(Sheet1!R[10]C:R[14]C,Sheet1!R[10]C[1]:R[14]C[1])"
      Range("A2").Select
      ActiveCell.FormulaR1C1 = _
          "=LINEST(Sheet1!R[9]C[2]:R[13]C[2],Sheet1!R[9]C[3]:R[13]C[3])"
      Range("A3").Select
      ActiveCell.FormulaR1C1 = _
          "=LINEST(Sheet1!R[8]C[4]:R[12]C[4],Sheet1!R[8]C[5]:R[12]C[5])"
      Range("A4").Select
      ActiveCell.FormulaR1C1 = _
          "=LINEST(Sheet1!R[7]C[6]:R[11]C[6],Sheet1!R[7]C[7]:R[11]C[7])"
      Range("A5").Select
  </code></pre>
  
  <p>Edit: added to code block</p>