Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 115
Default Macro to select MIN MAX from selection

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

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 638
Default Macro to select MIN MAX from selection

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


  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 115
Default Macro to select MIN MAX from selection

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



  #4   Report Post  
Posted to microsoft.public.excel.programming
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


Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
SELECT DUPLICATE IN SELECTION VIJAY BHARDWAJ Excel Worksheet Functions 2 March 9th 09 02:17 PM
Range(Selection, Selection.End(xlToRight)).Select Dave Birley Excel Programming 2 June 6th 07 04:53 PM
Select another Textbox After Selection Corey Excel Programming 1 February 21st 07 10:40 PM
Macro to select cells and then new selection from selected cells Rewop Eilsel Excel Programming 0 June 6th 06 04:25 PM
Selection.End(xlToLeft).Select Norbert Jaeger Excel Programming 1 August 12th 05 02:35 PM


All times are GMT +1. The time now is 09:56 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"