**Example 1 – **Using ISODD Function to Sort Odd and Even Numbers in Excel

We have added a Helper Column in the dataset where we will use the** ISODD** function.

**Steps:**

- Enter the following formula in cell
**D5**.

`=ISODD(C5)`

**Formula Breakdown**

**ISODD(C5)**→ The**ISODD**function returns TRUE when a number is odd, otherwise, the function returns FALSE.**Output:**FALSE

**Explanation:**Since cell**C5**contains an even number, the**ISODD**function returns FALSE.

- Press
**ENTER**. - You can see the result in cell
**D5**. - Use the
**Fill Handle**tool for the remaining cells.

- The output will be as shown below.

- We will sort the
**TRUE**and**FALSE**from**A to Z**. The Code No. will be sorted as*odd*and*even numbers.* - Select the entire Helper Column by selecting cells
**D5:D14**. - Go to the
**Home**tab >> select**Editing**. - From
**Sort & Filter**>> select**Sort Smallest to Largest**. - Select
**Sort Largest to Smallest**if you want to sort**Z to A**.

- A
**Sort Warning**will appear. - In the
**Sort Warning**dialog box, ensure that**Expand the selection**is marked. - Click on
**Sort**.

- The whole dataset will be sorted.

**Example 2 – **Use of IF, ISODD, and ISEVEN Functions to Sort Odd and Even Numbers in Different Columns

**Steps:**

- We will sort the odd numbers.
- Enter the following formula in cell
**D5**.

`=IF(ISODD(C5),C5," ")`

**Formula Breakdown**

**ISODD(C5)**→ The**ISODD**function returns TRUE when a number is odd, otherwise, the function returns FALSE.**Output:**FALSE

**IF(ISODD(C5),C5,” “)**→ becomes**IF(FALSE,C5,” “)****Output:**Blank Cell

**Explanation:**Since cell**C5**contains an even number, the**ISODD**function returns FALSE, and the**IF**function returns a blank cell.

- Press
**ENTER**. - You can see the output in cell
**D5**. - Use the
**Fill Handle**tool for the remaining cells.

** **

- The sorted odd numbers will be displayed in the Odd Numbers column.

- We will sort the even numbers.
- Enter the following formula in cell
**E5**.

`=IF(ISEVEN(C5),C5," ")`

**Formula Breakdown**

**ISEVEN(C5)**→ The**ISEVEN**function returns TRUE when a number is even, otherwise, the function returns FALSE.**Output:**TRUE

**IF(ISEVEN(C5),C5,” “)**→ becomes**IF(TRUE,C5,” “)****Output:**1234

**Explanation:**Since cell**C5**contains an even number, the**ISEVEN**function returns TRUE, and the**IF**function returns 1234.

- Press
**ENTER**. - You can see the result in cell
**E5**. - Use the
**Fill Handle**tool to apply the formula to the remaining cells.

- You can see the sorted even numbers in the Even Numbers column.

**Example 3 – **Sorting Odd and Even Numbers in an Ascending Order

We will use the combination of **IFERROR**, **IF**, **ROW**, **INDEX**, **MOD** and **SMALL** functions to sort odd and even numbers. This method is helpful when you want the odd or even numbers to be sorted in ascending order.

**Steps:**

- Enter the following formula in cell
**D5**.

`=IFERROR(SMALL(IFERROR(INDEX($C$5:$C$14,SMALL(IF(MOD($C$5:$C$14,2)=1,ROW($C$1:$C$10)),ROW($C$1:$C$10))),""),ROW(C1)),"")`

**Formula Breakdown**

**MOD($C$5:$C$14,2) →**the**MOD**function divides a number with a divisor and returns a reminder.**Output: {0;0;1;0;1;0;1;1;0;0}**

**MOD($C$5:$C$14,2)=1 →**becomes- {FALSE;FALSE;TRUE;FALSE;TRUE;FALSE;TRUE;TRUE;FALSE;FALSE})

**ROW($C$1:$C$10)**the**ROW**function**→**returns the row number of a range of cells.**Output:**{1;2;3;4;5;6;7;8;9;10}

**SMALL(IF(MOD($C$5:$C$14,2)=1,ROW($C$1:$C$10)),ROW($C$1:$C$10))),””) →**becomes**SMALL(IF{FALSE;FALSE;3;FALASE;5;FALSE;7;8;FALSE;FALSE},{1;2;3;4;5;6;7;8;9;10}))****Output:**{3;5;7;8;#NUM!;#NUM!;#NUM!;#NUM!;#NUM!;#NUM!})

**INDEX($C$5:$C$14,SMALL(IF(MOD($C$5:$C$14,2)=1,ROW($C$1:$C$10)),ROW($C$1:$C$10))),””) →**becomes**INDEX($C$5:$C$14{3;5;7;8;#NUM!;#NUM!;#NUM!;#NUM!;#NUM!;#NUM!})****Output:**{2367;7891;9981;8923;#NUM!;#NUM!;#NUM!;#NUM!;#NUM!;#NUM!}

**IFERROR(INDEX($C$5:$C$14,SMALL(IF(MOD($C$5:$C$14,2)=1,ROW($C$1:$C$10)),ROW($C$1:$C$10))),”” →**becomes**IFERROR({2367;7891;9981;8923;#NUM!;#NUM!;#NUM!;#NUM!;#NUM!;#NUM!})****Output:**{2367;7891;9981;8923;” ”;” ”;” ”!;” ”;” ”;” ”}

**ROW(C1)****→**becomes**Output:**1

**SMALL(IFERROR(INDEX($C$5:$C$14,SMALL(IF(MOD($C$5:$C$14,2)=1,ROW($C$1:$C$10)),ROW($C$1:$C$10))),””),ROW(C1)),””)****→**becomes**SMALL**(**{2367;7891;9981;8923;” ”;” ”;” ”!;” ”;” ”;” ”},1)****Output:**2367,” ”

**IFERROR(SMALL(IFERROR(INDEX($C$5:$C$14,SMALL(IF(MOD($C$5:$C$14,2)=1,ROW($C$1:$C$10)),ROW($C$1:$C$10))),””),ROW(C1)),””)****→**becomes**IFERROR(2367,” ”)****Output:**2367

- Press
**ENTER**. - The result will be in cell
**D5**. - Use the
**Fill Handle**tool for the remaining cells.

- You can see the complete Odd Numbers column.

- To sort the even number, enter the following formula in cell
**E5**.

`=IFERROR(SMALL(IFERROR(INDEX($C$5:$C$14,SMALL(IF(MOD($C$5:$C$14,2)=0,ROW($C$1:$C$10)),ROW($C$1:$C$10))),""),ROW(C1)),"")`

- The formula has only one difference from the previous one.
- We take
**MOD($C$5:$C$14,2)=0**because we want to get the even numbers and we want the reminder to become 0.

** **

- Press
**ENTER**. - You can see the output in cell
**E5**. - Use the
**Fill Handle**tool for the remaining cells in the column.

- You can see the complete Even Numbers column.

**Example 4 – **Inserting ISODD and MID Functions to Sort Odd and Even Numbers Between Texts

In the following dataset, you can see Code No. column contains both text and numbers. We will sort the even and odd numbers based on the middle number of the text.

**Steps:**

- A column named Helper Column has been added for calculation.
- Enter the following formula in cell
**C5**.

`=ISODD(MID(C5,4,2))`

**Formula Breakdown**

**MID(C5,4,2)**becomes**MID(“Y1-02-4Y”,4,2)****Output:**02

**ISODD(MID(C5,4,2))**becomes**ISODD(02)****Output:**FALSE

- Press
**ENTER**. - The result is in cell
**D5**. - Use the
**Fill Handle**tool for the remaining cells.

- The output will be as shown below.

- We will sort the
**TRUE**and**FALSE**from**A to Z**. The Code No. will be sorted as odd and even numbers. - Select the cell range
**D5:D14**. - Go to the
**Home**tab >> select**Editing**. - From the
**Sort & Filter Tab**>> select**Sort Smallest to Largest**. - You can select
**Sort Largest to Smallest**if you want to sort**Z to A**.

- In the
**Sort Warning**dialog box, ensure that**Expand the selection**is marked. - Click on
**Sort**.

- You can see the sorted Code No. column, where the middle number of the text strings has been sorted according to the even and odd numbers.

**Download Practice Workbook**

**<< Go Back to | Excel for Math | Learn Excel**