Basically what the title says. I have to make a function that takes in two arrays, and then it checks the max numerical value in the first array and spits out the corresponding text from array 2. How can I do this without using the max function?
Basically what the title says. I have to make a function that takes in two arrays, and then it checks the max numerical value in the first array and spits out the corresponding text from array 2. How can I do this without using the max function?
How many items are going to be in these arrays?
And what is the reason that "max" cannot be used?
This might be a start.
Change references where required
![]()
Sub Who_Knows() Dim a, b, i As Long, j As Double, jj As Long a = Range("J1:J" & Cells(Rows.Count, 10).End(xlUp).Row).Value b = Range("K1:K" & Cells(Rows.Count, 11).End(xlUp).Row).Value j = a(1, 1) jj = 1 For i = 2 To UBound(a, 1) If a(i, 1) > j Then j = a(i, 1): jj = i Next i MsgBox b(jj, 1) End Sub
Last edited by jolivanes; 03-06-2017 at 10:50 PM.
The LARGE() function could be used in place of the MAX() function, but, I don't see the reason for avoiding the use of the MAX() function. https://support.office.com/en-us/art...b-01672ec00a64
Originally Posted by shg
All you have to do now is hoping she does not read this and compares your solution to the suggestions here.
Like this
![]()
Dim arr1, arr2 arr1 = Array(3, 5, 1, 4, 0, 2) arr2 = Array("Apple", "Orange", "Bananna", "Peach", "Plum", "Pie") MsgBox arr2(WorksheetFunction.Large(arr1, 1))
Thanks,
Mike
If you are satisfied with the solution(s) provided, please mark your thread as Solved.
Select Thread Tools-> Mark thread as Solved.
There are currently 1 users browsing this thread. (0 members and 1 guests)
Bookmarks