sort by even or odd

  • Thread starter Thread starter Holstein
  • Start date Start date
H

Holstein

Can someone tell me how to sort a column by if a number
is odd or even. I would guess that I would need to use a
function in another column and first designate if the
number is even or odd. Can someone please tell me what
function this is or how to do this? Thanks in advance.
 
Hi

Look at the function ISODD

For eg if list is in column A put the following formula in
column b and drag down.

=isodd(a1)

And then sort by column B

Hope this helps
 
Hi
one way: add the following function in the adjacent column:
=IF(MOD(A1,2)=1,"Odd","Even")
copy down and sort with this column
 
Thank you both for your help. It works great. Thank you
again for your help. I appreciate it very much.
 
Frank
Can you tell me what this function is doing. I understand
that the A1 is the column with the number. What does MOD
do and what is the 2 and the =1? It works great but I'm
trying to learn as much as I can. Thanks again.
 
Hi
Mod returns the rest of a division. So in your case the cell A1 is
divided by two and the rest of this division is returned. e.g.
MOD(4,2) = 0
MOD(5,2) = 1
 
Holstein

If you check the Analysis Toolpak in Tools>Add-ins you can use either the
ISODD or ISEVEN function to return TRUE or FALSE in an adjacent column.

Sort or Filter on this column.

Assume column of numbers is A.

In B1 enter =ISODD(A1) and drag/copy down or double-click on B1 to copy down.

Gord Dibben Excel MVP
 
=MOD({cell-of-interest},2)=0 will give TRUE for even and FALSE for odd.

--
Regards,

Tushar Mehta
www.tushar-mehta.com
Excel, PowerPoint, and VBA add-ins, tutorials
Custom MS Office productivity solutions
 
Hi Tushar!

=MOD(INT(MyCell),2)=0
Replicates the Analysis Toolpak ISEVEN treatment of non integers.

But I'm inclined to prefer a FALSE response for numbers that are not exact
integers.

--
--
Regards
Norman Harker MVP (Excel)
Sydney, Australia
Excel and Word Function Lists (Classifications, Syntax and Arguments)
available free to good homes.

(e-mail address removed)
Excel and Word Function Lists (Classifications, Syntax and Arguments)
available free to good homes.
 
Hi Norman,

After a while, one either forgets or just gets sloppy. My intuitive
reaction to odd/even is to test for divisibility by 2. Though,
strictly speaking, it applies only to whole numbers, doesn't it?

The ATP is amazing. The more I learn about it the more I appreciate my
decision to minimize my reliance on it.

In any case, if one wanted to duplicate the ISEVEN functionality one
should TRUNC rather than INT. There's a difference when dealing with
negative numbers.

So, I guess a strict test for even would be
=IF(INT(X)<>X,NA(),MOD(X,2)=0)

--
Regards,

Tushar Mehta
www.tushar-mehta.com
Excel, PowerPoint, and VBA add-ins, tutorials
Custom MS Office productivity solutions
 
Hi Tushar!

Agreed on your revised version.

Also agreed on the minimization of reliance on Analysis ToolPak.

I'm not sure how mathematicians view it, but there is a possibility
that 1.1 should return FALSE rather than #NA!

Those ATP functions are due for a 10000 mile service.

--
Regards
Norman Harker MVP (Excel)
Sydney, Australia
(e-mail address removed)
Excel and Word Function Lists (Classifications, Syntax and Arguments)
available free to good homes.
 
Back
Top