Home » excel » excel – doing calculations on specific columns of array

excel – doing calculations on specific columns of array

Posted by: admin May 14, 2020 Leave a comment

Questions:

I populated a dynamic array using the data from a Table specific only on those rows that have a specific value in a specific column. Until this moment no probs. I’m unable though to do operations referred to one entire column (and only that column).

I thought about something like this

Dim arr as variant
Dim avg as double
Dim i as integer
i = InputBox( "The column I want to calculate the average of")
 avg = Application.Worksheetfunction.Average(arr.column(i))

Is it possible?

How to&Answers:

All you need is to change “column” to “columns”

Solution:

avg = Application.Worksheetfunction.Average(arr.columns(i))

Answer:

another possibility, worse in this case is the code i used was:

avg = application.worksheetfunction.average(application.index(array,0,i)) –