Index of Minimum Value in Array

afzalw

New Member
Joined
Jul 24, 2012
Messages
20
I have two Array Input(k) and Output(k).

I am looking to print Input(k) value for the corresponding minimum Output(k). This code is giving p = 1 but my minimum value is not at the index one in the array.
Code:
p = Application.Match(Application.Min(Output), Output, 0)
Debug.Print p

Set rDest = ThisWorkbook.Sheets("Design2").Cells(j, 16)                                  
rDest.Resize(1, 1).Value = Input(p)
 

Excel Facts

Formula for Yesterday
Name Manager, New Name. Yesterday =TODAY()-1. OK. Then, use =YESTERDAY in any cell. Tomorrow could be =TODAY()+1.
This worked for me:-
Code:
[COLOR="Navy"]Sub[/COLOR] MG22Mar36
[COLOR="Navy"]Dim[/COLOR] nOutput [COLOR="Navy"]As[/COLOR] Variant, nInput [COLOR="Navy"]As[/COLOR] Variant, P [COLOR="Navy"]As[/COLOR] [COLOR="Navy"]Long[/COLOR]
nOutput = Range("A1:A10")
nInput = Range("B1:B10")
  P = Application.Match(Application.Min(nOutput), nOutput, 0)
  Debug.Print P
  MsgBox nInput(P, 1)
[COLOR="Navy"]End[/COLOR] [COLOR="Navy"]Sub[/COLOR]

AB
110100
211101
312102
413103
52104
615105
716106
817107
918108
1019109
1120110
<colgroup><col width="27" style="width: 20pt; mso-width-source: userset; mso-width-alt: 967;"> <col width="64" style="width: 48pt;" span="2"> <tbody> </tbody>



Regards Mick
 
Upvote 0

Forum statistics

Threads
1,215,063
Messages
6,122,935
Members
449,094
Latest member
teemeren

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top