Filippo Mhri
Filippo Mhri

Reputation: 25

doing calculations on specific columns of array

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?

Upvotes: 1

Views: 62

Answers (2)

Filippo Mhri
Filippo Mhri

Reputation: 25

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

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

Upvotes: 1

piele
piele

Reputation: 78

All you need is to change "column" to "columns"

Solution:

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

Upvotes: 1

Related Questions