How to Perform Data Validation for Alphanumeric Only in Excel

Alphanumeric characters are a mix of alphabetical and numerical characters. There are 36 (A-Z and 0-9; case insensitive) or 62 (A-Z, a-z and 0-9; case sensitive) alphanumeric characters. In this article, we’ll show how to do the task of Excel Data Validation for alphanumeric only.

Overview Image


3 Easy Methods to Perform Data Validation for Alphanumeric Only in Excel

To demonstrate the methods, we will use the following dataset. The B column contains the Employee Id, the C column contains the Employee Name and the D column denotes if the Alphanumeric Status is OK. Here, we want to put in the B column only the Alphanumeric form. So, we will show you 3 easy methods of using custom formulas to do Data Validation for alphanumeric only. Let’s follow us to learn the methods.

Dataset


1. Using Custom Formula to Data Validate Any Alphanumeric

Here, the custom formula restricts characters except alphanumerics to be input in the specific column and also shows input types while the cursor sits on restricted cells. To ensure a custom formula works, we have to check its workability by applying it to the worksheet. We have Employee ID in alphanumerics, we check whether our custom formula returns TRUE or FALSE when assessing Employee IDs.

STEPS:

  • Firstly, type the following formula in the C5 cell.
=ISNUMBER(SUMPRODUCT(SEARCH(MID(B5,ROW(INDIRECT("1:"&LEN(B5))),1),"0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ")))
  • After typing, press ENTER to observe the result.

Inserting Formula for Finding Alphanumeric Status

In the formula, the MID function generates an array from the entered text in cell B3. Then the SEARCH function finds a text from “0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ” characters passing positions to the SUMPRODUCT function as Value. At last, the ISNUMBER function returns TRUE or FALSE depending on whether the cell references are alphanumeric or not.
  • After that, drag down the formula using the Fill Handle option to come up with results.

Dragging Down Formula Using Fill Handle Option

  • As you can see, we have alphanumeric characters in the Employee ID column.
  • Therefore, the custom formula returns TRUE for each entry.

Result After Finding Alphanumeric Status

  • Now, you can use the custom formula in the Data Validation feature to achieve what you desired at the beginning.
  • To do so, select the Employee ID column.
  • After selection, go to Data >> Data Tools >> Data Validation  >> Data Validation.

Inserting Excel Data Validation Option From Data Tab

  • Instantly, the Data Validation dialog box opens up.
  • In the Settings tab, choose Custom from the drop-down menu of the Allow field.
  • Then, write the following Custom formula inside the Formula box.
=ISNUMBER(SUMPRODUCT(SEARCH(MID(B1,ROW(INDIRECT("1:"&LEN(B1))),1),"0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ")))
  • Here, the formula is the same as we used to find out the Alphanumeric Status.

Data Validation window

  • Now, click on the Input Message section.
  • In the Input Message section, Type any Title (i.e., Input Type) and Input Message (i.e., Please Enter Alphanumeric Only) to guide the users.
  • When even users place their cursors in any Data Validated cells this preset Input Message appears.

Placing Input Message to Show

  • After that, click on the Error Alert tab.
  • In the Error Alert section, choose to Stop from the Style box.
  • Then, type a Title (i.e., Input Error) and Input Message (i.e., Please Enter Alphanumeric Only), you want to show whenever users input characters except for alphanumerics.
  • After that, press OK.

Inserting Error Message to Show After Error

  • Now, Place the cursor in any cell within column B.
  • Instantly, you’ll see a message box saying Input DataType Must be in Alphanumerics similar to the image below.

Showing Input Message Box

  • In case you want to test the formula, just Type any Non-alphanumeric in the B5 cell, and you’ll encounter an Input Error Message.
  • Therefore, we have successfully applied the custom formula.
  • Similarly, you can apply the custom formula in any cell or a range of cells.

Showing Error Message After Error


2. Applying Data Validation for Specific Alphanumerics Only

In this method, we want to allow users to input only specific alphanumerics in the worksheet. Let’s say we want the Employee IDs to be built with specific alphanumeric characters. Let’s follow the steps below to learn the method.

STEPS:

  • Firstly, insert specific alphanumeric characters in the D column.
  • After that, Give them a Defined Name (i.e., Characters) using the Name Box.

Defining Name for Data Range

  • Then, type Employee IDs consisting of allowed alphanumerics.
  • After that, to test the custom formula, Paste the custom formula to any adjacent cell (i.e., C5).
=COUNT(MATCH(MID(B5,ROW(INDIRECT("1:"&LEN(B5))),1),characters&"",0))=LEN(B5)
  • Then, press ENTER to observe the result.

Inserting Formula for Data Validation of Specific Alphanumerics Only

Here, the MID function creates an array using Cell Reference (i.e., B5) then the MATCH function matches the array to characters (works as a lookup_array; i.e., Allowed Alphanumeric). At last, the COUNT function declares that the Cell Reference is equal to the length of cell B3. The overall function returns it as TRUE or FALSE.

  • Now, drag down the formula using the Fill Handle option to bring up all the alphanumeric statuses for the Employee’s ID.

Dragging Down Formula

  • As a result, you can see the Alphanumeric Status of the Employee Ids.

Result After Getting Alphanumeric Status

  •  In the following step, select the B5:B13 range.
  • After selection, go to Data > > Data Tools >> Data Validation  >> Data Validation.

Inserting Excel Data Validation for Specific Alphanumeric Only

  • Instantly, the Data Validation window will open up.
  • In the newly opened window, go to the Settings tab.
  • Then, select Custom in the Allow field.
  • After that, write down the following formula in the Formula field.
=COUNT(MATCH(MID(B5,ROW(INDIRECT("1:"&LEN(B5))),1),characters&"",0))=LEN(B5)
  • Here, this formula is the same as we used before to find out the status.

Placing Formula for Doing Task of Data Validation for Specific Alphanuemeric Only

  • Now, click on the Input Message section.
  • In the Input Message section, Type any Title (i.e., Input Type) and Input Message (i.e., Please Enter Alphanumeric Only) to guide the users.
  • When even users place their cursors in any Data Validated cells this preset Input Message appears.

Placing Input Message to Show

  • After that, click on the Error Alert tab.
  • In the Error Alert section, choose to Stop from the Style box.
  • Then, type a Title (i.e., Input Error) and Input Message (i.e., Please Enter Alphanumeric Only), you want to show whenever users input characters except for alphanumerics.
  • After that, press OK.

Placing Error Message to Show After Occuring Error

  • Finally, return to the Excel Sheet.
  • Then, try to Input any characters except alphanumerics and the Input Error message window comes up.

Result After Inserting Non-Allowed Alphanumeric


3. Incorporating Data Validation of Fixed Length and Format Alphanumeric Only

In this method, we want to take the custom formula a step further by fixing the length and format of entries to apply Data Validation. In this case, we want case-sensitive alphanumerics to be present in Employee IDs with a fixed length (i.e.,10) and format. The first 3 characters in Employee IDs should be alphabetic and the rest 7 characters should be numeric. Let’s follow the steps below to learn the method:

STEPS:

  • Firstly, enter the Employee IDs maintaining the length (i.e.,10) and format (First 3 letters and the rest 7 numeric).
  • After writing, write down the following formula in the D6 cell.
=AND(LEN(B6)=10,LEN(SUBSTITUTE(B6," ","")<=3),ISNUMBER(1*RIGHT(B6,7)))
  • Then, press ENTER to watch the status.

Inserting Formula for Checking Data Validation of Fixed Length and Format Alphanumeric Only

Within the formula, the AND function declares three logical arguments; the first one is for the length (i.e., LEN(B6)=10), the second one is for the first three letters (i.e., LEN(SUBSTITUTE(B6,” “,””)<=3), and last one is for last seven numbers (i.e., ISNUMBER(1*RIGHT(B6,7))

  • Now, drag the Fill Handle to check whether the entries satisfy what we desire.
  • Here, TRUE declares the entries satisfy the requirements and FALSE otherwise.

Dragging Down Formula for Checking Data Validation of Fixed Length and Format Alphanumeric Only

  • As a result, you can see the Alphanumeric Status of the Employee Ids are TRUE.

Result After Checking Fixed Alphanumeric Status

  •  In the following step, select the B6:B14 range.
  • After selection, go to Data > > Data Tools >> Data Validation  >> Data Validation.

Inserting Data Validation Tool

  • Instantly, the Data Validation window will open up.
  • In the newly opened window, go to the Settings tab.
  • Then, select Custom in the Allow field.
  • After that, write down the following formula in the Formula field.
=AND(LEN(B6)=10,LEN(SUBSTITUTE(B6," ","")<=3),ISNUMBER(1*RIGHT(B6,7)))
  • Now, insert the entries in the Input Message and Error Alert tab.
  • Previously, we have shown the method.

Placing Formula for Checking Data Validation of Fixed Length and Format Alphanumeric Only

  • Finally, return to the Excel Sheet.
  • Now, place the cursor in any cell within the Range (i.e., B6:B14)
  • And, instantly, you’ll see an Input Message window.
  • After that, try to enter any non-alphanumeric characters (i.e.,!), you’ll encounter an Input Error as you set earlier Steps.

Showing Error Message After Inserting Non-Valid Alphanumeric


How to Use Data Validation for Specific Text Only in Excel

Suppose, we want to allow users to input only specific strings in the worksheet. Let’s follow the steps to learn the method.

STEPS:

  • Firstly, select the Allowed Alphanumeric column and define it as Characters.
  • Here, we have allowed writing the Id with the combination of any 8 given letters in the Characters column.

Defining Name for Data Range

  • After that, write down the following formula in the D5 cell:
=COUNT(MATCH(MID(B5,ROW(INDIRECT("1:"&LEN(B5))),1),characters&"",0))=LEN(B5)
  • Then, press OK to observe the result.

Inserting Formula for Data Validation of Specific Text Only

  • Now, drag down the formula using the Fill Handle option.

Dragging Down Formula to Alphanumeric Status with Fill Handle Option

  • As a result, you can see the Alphanumeric Status of the Employee ID.
  • IDs are the combination of 8 allowed letters, so the status is TRUE.

Result After Getting Alphanumeric Status

  • Then, select the B5:B13 range.
  • After selection, go to Data >> Data Tools >> Data Validation >> Data Validation.

Inserting Excel Data Validation Tool

  • Instantly, you can see the Data Validation window.
  • In the Settings tab, select Custom from the drop-down menu of the Allow field.
  • Then, in the Formula field, write down the following formula:
=COUNT(MATCH(MID(B5,ROW(INDIRECT("1:"&LEN(B5))),1),characters&"",0))=LEN(B5)
  • Now, insert the entries in the Input Message and Error Alert tab.
  • Previously, we have shown the method.

Placing Formula for Doing Task of Data Validation for Specific Text Only

  • Finally, return to the worksheet and place the cursor in any cell within the B5:B13 range, and the Input Message appears.
  • After that, try to Input any text except allowed strings, and the Input Error message window comes up.

Result After Inserting Non-Allowed Text


Practice Section

We have provided a practice section on each sheet on the right side for your practice. Please do it by yourself.

Practice Section


Download Practice Workbook

To practice by yourself, download the following workbook.


Conclusion

In this article, we saw Data Validation for alphanumerics only using three custom formulas. We developed three different custom formulas to comply with three different criteria. The first criterion is Data Validate any alphanumeric in a column, the second criterion is Data Validate only specific alphanumerics, and the last one is maintaining a string length Excel Data Validates a specific format for desired data types. There is a practice workbook at the beginning of the article. Go ahead and give it a try. Last but not least, please use the comment section below to post any questions or make any suggestions you might have.


Related Articles


<< Go Back to Excel Custom Data Validation | Data Validation in Excel | Learn Excel

Get FREE Advanced Excel Exercises with Solutions!
Maruf Islam
Maruf Islam

MARUF ISLAM is an excellent marine engineer who loves working with Excel and diving into VBA programming. For him, programming is like a superhero tool that saves time when dealing with data, files, and the internet. His skills go beyond the basics, including ABACUS, AutoCAD, Rhinoceros, Maxsurf, and Hydromax. He got his B.Sc in Naval Architecture & Marine Engineering from BUET, and now he's switched gears, working as a content developer. In this role, he creates techy content... Read Full Bio

We will be happy to hear your thoughts

Leave a reply

Advanced Excel Exercises with Solutions PDF

 

 

ExcelDemy
Logo