Check Whether an Excel Cell Contains One Dash and Two Digits
Question details
Check whether a cell contains exactly one dash followed by exactly two numeric digits.

- Product
- Microsoft Excel
- Device & OS
- not provided
- Scenario
- Validate text values and reject entries with extra dash-separated sections or nonnumeric suffixes.
- Observed behavior
- Valid entries should have one dash and end with two digits, such as ABC-12; invalid entries should be marked accordingly.
Identify the column containing the values to check and choose an empty helper column for the results. The formula below checks A1; change that reference if your first value is in another cell.
Use a Formula to Validate the Dash and Two Digits in Excel
Use a helper column to mark each value as OK or Not OK.
The formula requires exactly one dash and exactly two digits after it. It permits text before the dash, but does not require it.
Open the workbook in Excel and select B1, or another empty cell beside the value in A1.
In B1, enter =IFERROR(IF(AND(LEN(A1)-LEN(SUBSTITUTE(A1,"-",""))=1,LEN(A1)-FIND("-",A1)=2,ISNUMBER(FIND(MID(A1,FIND("-",A1)+1,1),"0123456789")),ISNUMBER(FIND(MID(A1,FIND("-",A1)+2,1),"0123456789"))),"OK","Not OK"),"Not OK") and press Enter.
Drag the fill handle from B1 down the helper column. Excel adjusts the A1 reference for each row.
Enter ABC-12 in a source cell to test a valid value. Try ABC-12-34, ABC-1A, and ABC-123 to confirm they return Not OK.

Check Dash-and-Digit Values in WPS Spreadsheet
Use a helper-column formula in WPS Spreadsheet to identify values with exactly one dash followed by two digits.
- 1. Open the spreadsheet: Launch WPS Spreadsheet and use Open to select your spreadsheet file.
- 2. Select a helper cell: Click B1, or an empty cell beside the first value. The formula below assumes the value is in A1.
- 3. Enter the validation formula: Enter =IFERROR(IF(AND(LEN(A1)-LEN(SUBSTITUTE(A1,"-",""))=1,LEN(A1)-FIND("-",A1)=2,ISNUMBER(FIND(MID(A1,FIND("-",A1)+1,1),"0123456789")),ISNUMBER(FIND(MID(A1,FIND("-",A1)+2,1),"0123456789"))),"OK","Not OK"),"Not OK") and press Enter.
- 4. Apply it to other rows: Drag the fill handle down the helper column to check the remaining values.

Frequently Asked Questions
Does the formula require text before the dash?
No. Both ABC-12 and -12 return OK. To require at least one character before the dash, add FIND("-",A1)>1 inside the formula's AND function.
Will a value with two dashes pass the check?
No. The LEN and SUBSTITUTE condition counts the dashes, so ABC-12-34 returns Not OK.
Can the two characters after the dash be letters?
No. Each character after the dash must be found in 0123456789. For example, ABC-1A returns Not OK.
How do I check values starting in A2 instead of A1?
Enter the formula in an empty cell such as B2 and replace every A1 reference with A2. Then drag the fill handle down to check the other rows.




