In continuation of my previous question I now need the maximum value contained within one column of the array.
I have a 2d array, with flexible dimensions:
arr_emissions(0 to n, 0 to m)
Where n
is 22 or larger (but no larger then around 400), and m
is 6 or larger.
In the smallest case column m = 6
contains the sum of columns m = 2 - 5
. I now need the maximum value of this column.
For 1d arrays there are plenty of examples of the usage of application.worksheetfunction.max
. So I thought to combine that with application.worksheetfunction.index()
as I did last time, but in this case the row number is a required argument, whilst I want the maximum value within a column, so from every row.
I tried wks_AI_res.Cells(row, 11).Value = Application.Max(Application.Index(arr_emissions, 0, emissions_rows))
which yields me the #VALUE error. In this the value of emissions_rows
= 6.
As the dimensions of the array are flexible I would like to implement a robust method, that preferly doesn't loop over the entire array.