title: How to get the average from multipe columns in VBA
body: <p>I have a table with the first row as header and the first column with student names, the rest of the cells have different student scores.</p>
  
  <p>I have to, on column O create a new header that says Average Score. Once that is done I have to calculate all the values from Columns B to Column N and then print out the average on each row of Column O.</p>
  
  <pre><code>Sub CalculateAverage()
  Dim rng As Range
  Dim totalsum As Double
  Dim totalnum As Double
  Dim answer As Double
      totalsum = 0
      totalnum = 0
  
  Set rng = Cells(1, 1).CurrentRegion
  
      For Each Sheet In Application.Worksheets
      Sheet.Cells(1, 15) = "Average Score"
      ActiveSheet.Cells.HorizontalAlignment = xlLeft
      Next
  
      For Each Sheet In Worksheets("Sheet1").Range("B2:N502").Cells
          totalsum = totalsum + Sheet.Value
          totalnum = totalnum + 1
      Next
  
      answer = totalsum / totalnum
      Average = answer
      Range("O2").Select
      ActiveCell.FormulaR1C1 = Average()
  End Sub
  </code></pre>
  
  <p>I am getting a debug error on the second last line.Can Anyone help me figure this out. Thanks</p>