I am trying to write a function that automatically deletes the minimum value for a given selection of cells. I know how to find the minimum value but I just don't know how to delete that value.
Here's what I've got.
Function MinDel(Stuff)
MinDel = Application.Worksheetfunction.min(stuff)
End Function
How do I delete the MinDel value?
Sub/ macro instead?WorksheetFunction.Minhere, because you're not interested in the result ofMin(stuff): it's the cell that contains this value that you're after, not the value itself. So you want theRangeobject with the smallest value in the providedstuff, assuming thisstuffis aRange, which would be much more explicit e.g. if the function signature wasPublic Function DeleteMinValue(ByVal stuff As Range), we'd know it wants aRangeand not just some array of values. Iterate (For Each) the cells instuff, yield a reference to the one with the smallest value.