I have a question regarding my function to return the largest number in a double array. This is what my current code looks like
Function return_largest()
last_row = Range("A1").End(xlDown).Row
Dim array_1()
ReDim array_1(last_row - 2, 5)
For i = 0 To last_row - 2
array_1(i, 0) = Range("A" & i + 2)
array_1(i, 1) = Range("B" & i + 2)
array_1(i, 2) = Range("C" & i + 2)
array_1(i, 3) = Range("D" & i + 2)
array_1(i, 4) = Range("E" & i + 2)
Next
MsgBox Application.WorksheetFunction.Max(array_1)
End Function
This function works for a 5x5 array. How should I change this code if I wish to make it a function usable for an array of dimensions (i,k)?
In other words, how could I write a function that finds the largest element for an array which can be called in a subprocedure for an array of size (x,y) (Whatever dimensions the array in the subprocedure has), and what is the syntax for that sub-procedure?
array_1 = Range("A1").Resize(100,5).Valuefor example. There is no need to use theReDimfunction to initialize it first.