1

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?

3
  • Do you have some sample data to go with this? Along with expected output and current result. Commented Nov 29, 2019 at 9:44
  • 2
    I DID IT! the code i used was: avg = application.worksheetfunction.average(application.index(array,0,i)) Commented Nov 29, 2019 at 9:56
  • @FilippoMhri As this is now solved can you either close your question or better yet, write your comment as an answer and accept it? Commented Nov 29, 2019 at 10:35

2 Answers 2

1

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

Solution:

avg = Application.Worksheetfunction.Average(arr.columns(i))
Sign up to request clarification or add additional context in comments.

3 Comments

How does this work? I can't get it to work with an array
Are you trying to calculate the average of an array? Simply do: Application.Worksheetfunction.Average(ArrayName)
that doesn’t work on a non-2D array which is what the question is asking
1

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

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

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.