You are here:

Excel/Conditional formula question


With my clients, they get placed into 2 categories based on the last 2 numbers of their ID number, I am trying to write a formula that will place an indicator in a cell based on what the last 2 numbers of their ID number.  For example, 432048210 would indicate a male client, and 432041220 would indicate a female client.  Is there a way to write a formula to have a wildcard and look for those indicators and place the result in another cell?  Thank you in advance, I have tried every conditional operation that I could think of and am stumped.

Hello Cindy,

Thank you for your question.  I believe I can help you with this.

However, I am not for sure if you are wanting something (like "Male" or "Female") placed in an adjacent cell, or, if you are wanting the ID number formatted differently for male and female clients.  Since the subject was Conditional Formula question, I assume you want a conditional formatting.  But I will give you a solution for both.

First, let's assume your data is in Column A with the first ID number in A1.  If not, then adjust the formulas I provide to match your data.  In Cell B1, place this formula:


Then copy and paste the formula down as far as your data extends. Since the ID number of male clients ends in "10," all ID numbers ending in "10" will say "Male."  The other ID numbers will say "Female" by default.

If you want something other than "Male" or "Female" in the cell, then change that part of the formula I gave you.

Conditional Formatting Solution.  If you are wanting the ID numbers to be formatted to easily identify them as male or female, then the steps below will do that.

First, highlight the range of data (the list of ID numbers).  Depending upon which version of Excel you are using, go to the Home tab and click on Conditional Formatting. Click on "New Rule" and then click on "Use a formula to determine which cells to format."  You will then see a box to place a formula.  Place this formula: =(RIGHT(A1,2)="10")and then click the format button just below and select the formatting you want the cell to have for the male clients.  Then repeat the action (New Rule, etc) and use the same formula, except change the "10" to "20" and select the formatting you want for the female clients.

I hope this helped and that one of the solutions is what you were looking for.  If not, send me a follow-up and we will keep at it until we get it the way you want it.

Good luck.


About Excel
This topic answers questions related to Microsoft Excel spreadsheet (or workbook) stand-alone or Mircrosoft Office Excel including Excel 2003, Excel 2007, Office 2000, and Office XP. You can get Excel help on Excel formulas(or functions), Excell macros, charting in Excel, advanced features, and the general use of Excel. This does not provide a general Excel tutorial nor the basics of using a spreadsheet. It provides specific answers to using Microsoft Excel only. If you do not see your Excel question answered in this area then please ask an Excel question here


All Answers

Answers by Expert:

Ask Experts


David W. Cofer


I can answer MS Excel questions regarding Excel Formulas, Functions, Worksheets, Data Validation, Conditional Formating, Lookup, Pivot Tables and Logic Functions, as well as other general Excel questions. I do not answer questions regarding Charts, Macros, Visual Basic or Programming. Please include the version of Excel you are using. That helps me provide an answer that will work on your system. Also, do not submit duplicate questions to several experts at the same time. If several of us are answering the same question at the same time, it is a waste of time and resources. If the first expert you ask does not provide an acceptable answer, then ask a second expert. As we are volunteers, our time is valuable, and it is a waste of time for 5 of us to be working on the same question at the same time. Thanks for your understanding.


I have used MS Excel for over 20 years and am familiar with all versions back to 1993. I currently use Excel 2013 and assist those using versions going back to 2000. I use Excel extensively at both work and home.

I hold a B.A. degree in Psychology.

©2017 All rights reserved.