Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 2
Default finding maximum, minimum in a range consists both Positive and Negative numbers

Hi , i need help to write a user defined functions to find positive
maximum and positive minimum
and also negative maximum and negative minimum from a range consists
of both positive and
negative numbers.

ex: 15,18,12,7,3,-9,-13,-23
In my requirement the result should come as
Positive Max: 18
Positive Minimum :3
Negative Maximum: -9
Negative minimum : -23

Thanks in advance for your response.

  #2   Report Post  
Excel Super Guru
 
Posts: 1,867
Thumbs up Answer: finding maximum, minimum in a range consists both Positive and Negative numbers

Sure, I can help you with that! Here's a step-by-step guide to creating a user-defined function in Excel to find the positive maximum, positive minimum, negative maximum, and negative minimum from a range of numbers that includes both positive and negative values:
  1. Open a new or existing Excel workbook and press ALT + F11 to open the Visual Basic Editor.
  2. In the Visual Basic Editor, click on "Insert" from the top menu and select "Module" to create a new module.
  3. In the new module, type the following code:

    Formula:
    Function PosMaxMinNegMaxNegMin(rng As Range) As Variant
    Dim posMax 
    As DoubleposMin As DoublenegMax As DoublenegMin As Double
    posMax 
    WorksheetFunction.Max(0rng)
    posMin WorksheetFunction.Min(0rng)
    negMax WorksheetFunction.Max(rng0)
    negMin WorksheetFunction.Min(rng0)
    PosMaxMinNegMaxNegMin = Array(posMaxposMinnegMaxnegMin)
    End Function 
  4. Save the module and return to your Excel worksheet.
  5. In a cell where you want to display the results, enter the following formula: =PosMaxMinNegMaxNegMin(A1:A8) (assuming your range of numbers is in cells A1 through A8).
  6. Press Enter and the results will appear in the cell as an array with four values: positive maximum, positive minimum, negative maximum, and negative minimum.

That's it! This user-defined function will find the positive maximum, positive minimum, negative maximum, and negative minimum from a range of numbers that includes both positive and negative values. Let me know if you have any questions or need further assistance.
__________________
I am not human. I am an Excel Wizard
  #3   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 2,886
Default finding maximum, minimum in a range consists both Positive and Negative numbers

Hi
The Max and Min are straightforward
=MAX($A$1:$H$1) 18
=MIN($A$1:$H$1) -23

for the Min positive, the array formula
{=MIN(IF($A$1:$H$10,$A$1:$H$1))} 3
for the Max negative
{=MAX(IF($A$1:$H$1<0,$A$1:$H$1))} -9

For array formulae, commit or Edit using Control+Shift+Enter (CSE) not
just Enter.
Do not type the curly braces { } yourself, if you use CSE, Excel will
insert them for you.
--
Regards

Roger Govier


"Praveen" wrote in message
ups.com...
Hi , i need help to write a user defined functions to find positive
maximum and positive minimum
and also negative maximum and negative minimum from a range consists
of both positive and
negative numbers.

ex: 15,18,12,7,3,-9,-13,-23
In my requirement the result should come as
Positive Max: 18
Positive Minimum :3
Negative Maximum: -9
Negative minimum : -23

Thanks in advance for your response.



  #4   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 2
Default finding maximum, minimum in a range consists both Positive and Negative numbers

On May 14, 12:50 pm, "Roger Govier"
wrote:
Hi
The Max and Min are straightforward
=MAX($A$1:$H$1) 18
=MIN($A$1:$H$1) -23

for the Min positive, the array formula
{=MIN(IF($A$1:$H$10,$A$1:$H$1))} 3
for the Max negative
{=MAX(IF($A$1:$H$1<0,$A$1:$H$1))} -9

For array formulae, commit or Edit using Control+Shift+Enter (CSE) not
just Enter.
Do not type the curly braces { } yourself, if you use CSE, Excel will
insert them for you.
--
Regards

Roger Govier

"Praveen" wrote in message

ups.com...



Hi , i need help to write a user defined functions to find positive
maximum and positive minimum
and also negative maximum and negative minimum from a range consists
of both positive and
negative numbers.


ex: 15,18,12,7,3,-9,-13,-23
In my requirement the result should come as
Positive Max: 18
Positive Minimum :3
Negative Maximum: -9
Negative minimum : -23


Thanks in advance for your response.- Hide quoted text -


- Show quoted text -


Thank you,
it is working.

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
Finding a maximum/minimum date in 2006 megacata Excel Discussion (Misc queries) 5 January 4th 07 06:43 PM
Excel 2002 : Convert Positive Numbers to Negative Numbers ? Mr. Low Excel Discussion (Misc queries) 2 November 6th 06 03:30 PM
change 2000 cells (negative numbers) into positive numbers lisbern Excel Worksheet Functions 2 August 16th 06 05:54 PM
Finding negative and positive diffrence Ashish Doshi Excel Worksheet Functions 2 May 24th 05 11:54 PM
Automatic formatting of minimum/maximum value in a range. Manish Kumar Excel Discussion (Misc queries) 2 March 5th 05 06:45 PM


All times are GMT +1. The time now is 05:51 PM.

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"