vba to find min value in an array

dillard720

New Member
Joined
Oct 12, 2011
Messages
11
I have an array, lminconstraint(icolumn), that holds the value of cells 0 to 18 if those cells have a value.

I need to find the minimum value for that array. Can you help?
 

Excel Facts

How to fill five years of quarters?
Type 1Q-2023 in a cell. Grab the fill handle and drag down or right. After 4Q-2023, Excel will jump to 1Q-2024. Dash can be any character.
Perhaps Like ??
Code:
Dim Rng As Range
Dim Ray
Set Rng = Range(Range("A1"), Range("A" & Rows.Count).End(xlUp))
Ray = Rng.Value
MsgBox Application.Min(Ray)
 
Upvote 0
I'm not sure that will work. My array values vary and are not always numeric. In this particular example my values are the following:

lminConstraint = (Empty, Empty,Empty,Empty,Empty,2498,Empty,Empty,Empty,Empty,1601,Empty,Empty,Empty,Empty)

Each time I run the code the values will be different based on an array before this one. I need to find the min value of the array lminConstraint each time.
 
Upvote 0
Hi

What does

MsgBox Application.Min(lminConstraint)

return? It should return the lowest value. Do you need to know the position of the minimum value?
 
Upvote 0
That does give me the answer, I just don't need it in a message box. I need to assign that value to another variable to use in the next part of my code.

Can I do something like:

vMinConstraint = Application.Min(lMinConstraint)
 
Upvote 0
i have one row and 5columns.(row-a, columns-a,b,c,d,e)
nd each of the cells have a value.(eg: 256,5255 etc). i have written a code to extract the last digit of al the values and stored them in an array.
now my question is how to find the min of al the values stored in the array and its respective position in the excel sheet.

can some1 help me out in this.


thanks in advance :)
 
Upvote 0

Forum statistics

Threads
1,213,534
Messages
6,114,185
Members
448,554
Latest member
Gleisner2

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