I want to create a customised function to find the max value of each "row" in an array. For example, I have a sample 5x3 dimensions array as below:
[ 0 0 0
0 1 1
1 0 1
1 1 1
0 0 0]
And I want to get the max value of each row which should come in the form of: [0 1 1 1 0]
Please note that this is just one example. I'm facing quite a number of matrices which require this task. I did some research online but couldn't find an easy solution for this. There is one which I found requires output into the spreadsheet before finding the max values (the outputting into spreadsheet is not preferred though). This code is below:
Function Max_Each_Row(Data_Range As Range) As Variant
Dim TempArray() As Double, i As Long
If Data_Range Is Nothing Then Exit Function
With Data_Range
ReDim TempArray(1 To .Rows.count)
For i = 1 To .Rows.count
TempArray(i) = Application.Max(.Rows(i))
Next
End With
Max_Each_Row = TempArray
End Function
Could someone point me to the right direction? i.e. creating a function () to find the desired array with the max value in each row, without outputting anything into the spreadsheet.
Thanks for your help!