# Determining If a Number is Odd or Even

Please Note: This article is written for users of the following Microsoft Excel versions: 97, 2000, 2002, and 2003. If you are using a later version (Excel 2007 or later), this tip may not work for you. For a version of this tip written specifically for later versions of Excel, click here: Determining If a Number is Odd or Even.

A common programming task is validating user input. Often, your macro may need to determine if a number entered by a user is odd or even. For instance, suppose you wrote your own macro that asked the user what worksheet number they wanted to process. If your macro had to process odd and even worksheets differently, then you need to figure out if the number the user provided was odd or even. The technique for this is relatively simple, as shown here:

```Even = (UserNum Mod 2) - 1
```

After execution of this line, Even will be True (-1) if UserNum was even, or False (0) if UserNum was odd.

ExcelTips is your source for cost-effective Microsoft Excel training. This tip (2273) applies to Microsoft Excel 97, 2000, 2002, and 2003. You can find a version of this tip for the ribbon interface of Excel (Excel 2007 and later) here: Determining If a Number is Odd or Even.

Related Tips:

Comprehensive VBA Guide Visual Basic for Applications (VBA) is the language used for writing macros in all Office programs. This complete guide shows both professionals and novices how to master VBA in order to customize the entire Office suite for their needs. Check out Mastering VBA for Office 2010 today!

 *Name: Email: Notify me about new comments ONLY FOR THIS TIP Notify me about new comments ANYWHERE ON THIS SITE Hide my email address *Text: *What is 5+3 (To prevent automated submissions and spam.)

There are currently no comments for this tip. (Be the first to leave your comment—just use the simple form above!)

# Our Company

Sharon Parq Associates, Inc.

# Our Sites

Tips.Net

Beauty and Style

Cars

Cleaning

Cooking

ExcelTips (Excel 97–2003)

ExcelTips (Excel 2007–2016)

Gardening

Health

Home Improvement

Money and Finances

Organizing

Pests and Bugs

Pets and Animals

WindowsTips (Microsoft Windows)

WordTips (Word 97–2003)

WordTips (Word 2007–2016)

Excel Products

Word Products

# Our Authors

Author Index

Write for Tips.Net