Message 1 of 12
New to VBA

Not applicable
03-21-2017
12:50 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Hi
I have some code that looks for the Min and Max in an array and then removes the Min and Max. My array has always 4 values now what i want to do is when the Min and Max are removed from the array is to use the other 2 values in mathformulas is that possible ?
So lets say P1 is the Min and P4 is the Max so i have P3 and P2 and i want to use P3 and P2 in some mathformulas.
'create list of values Dim MyArrayList As New ArrayList MyArrayList.add(p1) MyArrayList.add(p2) MyArrayList.add(p3) MyArrayList.add(p4) 'find mininum oMin = MinOfMany(p1, p2, p3, p4) 'look at each item in the list and 'remove if it matches minimum For Each oItem in MyArrayList If oItem = oMin Then MyArrayList.Remove(oItem) Exit For End If Next 'find maximum oMax = MaxOfMany(p1, p2, p3, p4) 'look at each item in the list and 'remove if it matches maximum For Each oItem in MyArrayList If oItem = oMax Then MyArrayList.Remove(oItem) Exit For End If Next 'get user input oInput = InputListBox("Choose one", MyArrayList, "", "iLogic", "Values") If oInput = "" Then Return 'do nothing if nothing is selected 'deplay selected value MessageBox.Show("You selected: " & oInput, "iLogic")
thanks in advance