Average multiple columns
To average all values in multiple columns you can apply an Excel or a VBA method using the Excel AVERAGE function
Example: Average multiple columns
=AVERAGE(C:D)
|
The formula uses the Excel AVERAGE function to average all of the numbers in columns C and D.
|
Sub Average_multiple_columns()
'declare a variable
Dim ws As Worksheet
Dim ws As Worksheet
Set ws = Worksheets("Analysis")
'apply the formula to average all numbers in columns C and D
ws.Range("F5") = Application.WorksheetFunction.Average(ws.Range("C:D"))
ws.Range("F5") = Application.WorksheetFunction.Average(ws.Range("C:D"))
End Sub
OBJECTS
Worksheets: The Worksheets object represents all of the worksheets in a workbook, excluding chart sheets.
Range: The Range object is a representation of a single cell or a range of cells in a worksheet.
Worksheets: The Worksheets object represents all of the worksheets in a workbook, excluding chart sheets.
Range: The Range object is a representation of a single cell or a range of cells in a worksheet.
PREREQUISITES
Worksheet Name: Have a worksheet named Analysis.
Data Range: Ensure that the data that you want to average from is captured in range ("C:D") in the Analysis worksheet.
Worksheet Name: Have a worksheet named Analysis.
Data Range: Ensure that the data that you want to average from is captured in range ("C:D") in the Analysis worksheet.
ADJUSTABLE PARAMETERS
Date Range: Select the columns that you want to average by changing range ("C:D") to any range in the worksheet, that doesn't conflict with the formula.
Output Range: Select the output range by changing the cell reference ("F5") to any cell in the worksheet, that doesn't conflict with the formula.
EXPLANATION
To average all values in multiple columns you can apply an Excel or a VBA method. The formula used to average values in multiple columns is driven by an Excel AVERAGE function.
In both the VBA and Excel examples the formula averages all of the numbers in columns C and D. This is achieved through the use of the Excel AVERAGE function.
To average all values in multiple columns you can apply an Excel or a VBA method. The formula used to average values in multiple columns is driven by an Excel AVERAGE function.
In both the VBA and Excel examples the formula averages all of the numbers in columns C and D. This is achieved through the use of the Excel AVERAGE function.
FORMULA
=AVERAGE(column_references)
=AVERAGE(column_references)
ARGUMENTS
column_references: The columns which you want to average.
column_references: The columns which you want to average.