View Single Post
  #4   Report Post  
Posted to microsoft.public.excel.programming
JW[_2_] JW[_2_] is offline
external usenet poster
 
Posts: 638
Default Macro to select MIN MAX from selection

I would STRONGLY urge that you handle the DIV/0 error in your
formula. You can do this using IsErr, IsError, or an Or statement.
=IF(OR(A2=0,B2=0),0,A2/B2)
=IF(ISERR(A2/B2),0,A2/B2)

wrote:
Jeff, Thanks. Is there any way to ignore the #DIV/0! in the selection
and return the min and max of the selection?

On Oct 18, 11:28 am, JW wrote:
Sub getMinMax()
Dim minValue As Double
Dim maxValue As Double
maxValue = WorksheetFunction.Max(Selection)
minValue = WorksheetFunction.Min(Selection)
MsgBox "minimum value: " & minValue & Chr(10) & _
"maximum value: " & maxValue
End Sub

wrote:
If the user hits the command button, what would be the macro to find
the minimum and maximum of the users selection.


In excel front end, it is done by using = min( ) and =max( )


Can the code be tweaked to ignore any alphabets/words from the
selection and find the min and max for the only the numbers in the
selection?


I would appreciate anyone willing to assist me in this.


Marvin