Excel Data Validation for X, Slash, or Whole Numbers 5 to 29
Question details
Create a custom data validation rule that accepts x, a slash, or a whole number from 5 through 29.

- Product
- Microsoft Excel
- Device & OS
- not provided
- Scenario
- Restrict entries in a selected range to specific characters or whole numbers within a defined range.
- Observed behavior
- Cells should accept x, /, and whole numbers from 5 to 29, but reject other entries.
Identify the range you want to validate and note its first cell. The examples below use H2:H50 with H2 as the active cell.
Create a custom validation rule in Excel
Use one formula to allow x, a slash, or a whole number from 5 through 29.
Select H2:H50, starting with H2 so that H2 is the active cell. For a different range, use its first cell in the formula.
On the Data tab, select Data Validation. On the Settings tab, choose Custom from the Allow list.
In the Formula box, enter =OR(H2="x",H2="/",IFERROR(AND(ISNUMBER(H2),H2>=5,H2<=29,MOD(H2,1)=0),FALSE)). Replace each H2 reference with the first cell of your selected range if necessary.
Clear Ignore blank if blank entries should not be allowed. On the Error Alert tab, enable the alert and select Stop, then click OK. Test entries such as x, /, 5, 29, 4, and 5.5.

Set the same entry restrictions in WPS Spreadsheets
Use a custom data validation formula in WPS Spreadsheets to restrict a range to x, /, or whole numbers from 5 through 29.
- 1. Open the workbook: Open WPS Spreadsheets and use File > Open to select your workbook.
- 2. Select the range: Select H2:H50, starting with H2 so it is the active cell.
- 3. Add a custom rule: On the Data tab, open Validity or Data Validation and choose Custom. Enter =OR(H2="x",H2="/",IFERROR(AND(ISNUMBER(H2),H2>=5,H2<=29,MOD(H2,1)=0),FALSE)) in the formula box.
- 4. Apply and test: If blanks should be rejected, clear Ignore blank. Enable a Stop error alert, apply the rule, and test entries including x, /, 5, 29, and 5.5.

Frequently Asked Questions
Will the rule accept uppercase X?
Yes. The formula compares text without regard to case, so both x and X are accepted.
How do I apply the formula to a different range?
Select the range starting with its first cell, then replace each H2 in the formula with that active cell reference before applying the Custom rule.
Will decimals or numbers outside 5 through 29 be accepted?
No. The formula checks that a number is between 5 and 29 and that MOD(value,1) equals zero, so decimals and out-of-range numbers are rejected.
Does data validation remove invalid values already in the cells?
No. Review existing entries separately after adding the rule; the validation alert primarily applies when entries are made or changed.
How can I prevent blank entries?
In the Data Validation Settings tab, clear Ignore blank. This does not automatically fill or remove cells that are already empty.




