Custom Data Validation in Excel

If you just need to custom data validation in excel and move on, the boxed answer at the top is all you need. The rest of this page is for when you want to understand why it works in Excel, adapt it to a trickier version, or make it robust enough to hand to a colleague. We keep the opening short on purpose — the depth is here when you want it, not in your way when you don’t.

Exact answer

In Excel: select the cells, open Data ▸ Data Validation, choose Allow: Custom and enter a formula that returns TRUE for valid entries, written for the first selected cell — for example =COUNTIF($A$2:$A$100,A2)=1 rejects a duplicate in A2:A100.

On this page7
▤Annotated stepsExcel
1

Select the range starting from its first cell, so that cell is active (for example A2:A100 with A2 active).

2

Open Data ▸ Data Validation and choose Allow: Custom on the Settings tab.

3

Enter the rule, for example =COUNTIF($A$2:$A$100,A2)=1, using the active cell for the relative reference.

4

On the Error Alert tab keep Style: Stop and write a message that says what is allowed.

5

Test one valid and one invalid entry, then use Data ▸ Data Validation ▸ Circle Invalid Data to find existing violations.

=COUNTIF($A$2:$A$100,A2)=1
Ctrl+CthenCtrl+Shift+V⌘+Cthen⌘+Ctrl+VPaste values · WindowsMac

What this does

Custom is the Data Validation type for rules that List, Whole number, Date or Text length cannot express. Excel evaluates the formula for each cell as if it were entered in that cell: TRUE accepts the entry, FALSE rejects it with the Error Alert. The formula is written relative to the active cell of the selection, so references that should move with each row stay relative (A2) and fixed ranges get $ signs. Validation checks only what is typed; values pasted over the cells or filled into them are not checked, which is what Data ▸ Data Validation ▸ Circle Invalid Data is for. The same idea underpins a lot of everyday Excel work, so the few minutes spent getting it right here pay back across every sheet you build afterwards. Treat it as a pattern, not a one-off, and it stops being something you look up and starts being something you reach for. The difference between a quick fix and a sheet you can trust is the extra minute you spend validating “custom data validation in excel”. Start on a copy or a tiny sample, keep the affected cells visible, and compare the result with the outcome you expected before you touch the real workbook. When a formula is involved, keep the inputs labelled beside it, reference cells instead of typing values, and apply number formatting only after the result checks out. The point is a data step that keeps your analysis trustworthy, but the practical win is that someone else can open the file and understand what happened without asking you.

A worked example

Product codes in A2:A100 must be unique and exactly 5 characters long. Select A2:A100 with A2 active, choose Allow: Custom and enter =AND(LEN(A2)=5,COUNTIF($A$2:$A$100,A2)=1). Typing AB123 in A2 is accepted. Typing AB123 again in A7 is rejected, because COUNTIF now finds it twice; typing AB12 in A8 is rejected, because LEN returns 4. Many entry rules — unique IDs, fixed-length codes, end dates after start dates — are conditions rather than lists. A custom formula enforces them while people type, before bad values spread into lookups and totals. Check the referenced cells, argument order and result type in your workbook. Start with the worked example before changing an input, then compare the changed result with the calculation you expected. An error value or a result of a different type is a reason to inspect the inputs and arguments.

In Google Sheets

The standard worksheet functions used by this example are listed in Google Sheets. Check the cell references, argument separators and input types in the target spreadsheet, then compare the worked result. This formula-availability check does not establish identical menus, keyboard shortcuts or workbook features, and it is not a product execution test. The aim was to get you unstuck fast and leave you a little more capable than a copy-paste would. The answer is at the top and the detail above shows why it holds — so the next time a colleague asks, you can answer without reaching for search. For “custom data validation in excel”, keep the input cells and the result visible while you check the formula in Excel. Follow the worked example and change one input at a time. The steps explain the workbook calculation; this page does not run a live calculator for that task.

Common mistakes

  • Writing the formula for a cell other than the active one, so every row checks the wrong neighbour.
  • Forgetting $ on the fixed range, which makes the range slide down row by row.
  • Choosing Allow: List for a rule that is really a condition; List only offers fixed choices.
  • Expecting the rule to stop pasted values — pasting and filling are not validated.

Frequently asked questions

What is the difference between List and Custom?

List offers a fixed set of choices in a drop-down. Custom has no drop-down; it accepts any typed value for which your formula returns TRUE.

Can a custom rule depend on another column?

Yes — applied to B2:B50, =B2>=A2 only accepts an end date on or after the start date in the same row of column A.

Why are existing wrong values not flagged?

Validation runs when a value is typed. Use Circle Invalid Data to mark existing cells that break the rule.