# Returning greatest (absolute) value, including negatives

1. ## Returning greatest (absolute) value, including negatives

Hi,

I have a range of numbers from -100 to 100 in a row, and would like to return the greatest absolute value, including the negative sign if it happens to be a negative value.

i.e. if the number happens to be -70, using the =ABS function only returns "70", instead of -70.
Using the =MAX function also only returns the greatest positive value, even if there is a larger negative absolute value.

Thanks

2. ## Re: Returning greatest (absolute) value, including negatives

Use this:

``Please Login or Register  to view this content.``
Entered with Ctrl-Shift-Enter.

Cheers,

3. ## Re: Returning greatest (absolute) value, including negatives

Sorry, I've done the above, but it still returns any negative values as its positive (i.e. without the negative sign).

4. ## Re: Returning greatest (absolute) value, including negatives

Maybe

=MAX(ABS(MIN(A1:A10)),MAX(A1:A10))*IF(ABS(MIN(A1:A10))>MAX(A1:10),-1,1)

5. ## Re: Returning greatest (absolute) value, including negatives

Try

=INDEX(A1:A10,MATCH(MAX(ABS(A1:A10)),ABS(A1:A10),0))

confirmed with CTRL+SHIFT+ENTER

6. ## Re: Returning greatest (absolute) value, including negatives

The above works perfectly, thanks for the fast reply.

Just one minor point, what if the cells were non-continguous? I keep getting syntax errors trying to pick individual cells, as oppose to A1:A10.

7. ## Re: Returning greatest (absolute) value, including negatives

How many cells? Is there a pattern like every other row or every 4 columns?

8. ## Re: Returning greatest (absolute) value, including negatives

Another alternative

=IF(ABS(MIN(A1:A10))>MAX(A1:A10),MIN(A1:A10),MAX(A1:A10))

9. ## Re: Returning greatest (absolute) value, including negatives

The number of cells varies from 2-3 (for the sake of the formula, assume its E2, J2, M2).

I'm happy to pick them out myself, however, the syntax is apparently wrong, and it won't let me do that.

10. ## Re: Returning greatest (absolute) value, including negatives

Well, I think Cutter has cracked it - his version allows you to use a discontiguous range, i.e.

=IF(ABS(MIN(E2,J2,M2))>MAX(E2,J2,M2),MIN(E2,J2,M2),MAX(E2,J2,M2))

....or my own variation on that.....

=SUBTOTAL(4+(ABS(MIN(E2,J2,M2))>MAX(E2,J2,M2)),E2,J2,M2)

11. ## Re: Returning greatest (absolute) value, including negatives

Thats it, thanks everyone.

12. ## Re: Returning greatest (absolute) value, including negatives

Originally Posted by daddylonglegs
Try

=INDEX(A1:A10,MATCH(MAX(ABS(A1:A10)),ABS(A1:A10),0))

confirmed with CTRL+SHIFT+ENTER
My apologies to bump this up.

Hello daddylonglegs,
Your provided formula did works well for getting the maximum values with signs.

Can you please teach how to write this simply for VBA module use, example by using worksheetfunction or application.
I will insert the VBA function to an existing module to get the answer at cell B1

Cells(2, 1).Value = __________

Thank you.

13. ## Re: Returning greatest (absolute) value, including negatives

@pilak,
1. Unfortunately your post does not comply with Rule 2 of our Forum RULES. Do not post a question in the thread of another member -- start your own thread.

If you feel an existing thread is particularly relevant to your need, provide a link to the other thread in your new thread.

Old threads are often only monitored by the original participants. New threads not only open you up to all possible participants again, they typically get faster response, too.

2. Don't quote whole posts -- it's just clutter. If you are responding to a post out of sequence, limit quoted content to a few relevant lines that makes clear to whom and what you are responding

For normal conversational replies, try using the QUICK REPLY box below.

14. ## Re: Returning greatest (absolute) value, including negatives

both the numbers are returning me exponential results. what to do?

15. ## Re: Returning greatest (absolute) value, including negatives

Administrative Note:

Welcome to the forum.

We are happy to help, however whilst you feel your request is similar to this thread, experience has shown that things soon get confusing when answers refer to particular cells/ranges/sheets which are unique to your post and not relevant to the original.

Please see Forum Rule #4 about hijacking and start a new thread for your query.

If you are not familiar with how to start a new thread see the FAQ: How to start a new thread

#### Thread Information

##### Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

#### Posting Permissions

• You may not post new threads
• You may not post replies
• You may not post attachments
• You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1