Skip to main contentSkip to solution

Which formula can be used to prevent leading or trailing spaces in a data validation rule?

Solution

✅ Correct Option: 1

The formula =TRIM(A1)=A1 is used to prevent leading or trailing spaces in data validation.

The TRIM function removes all leading and trailing spaces from text. When we compare TRIM(A1) with A1:

  • If A1 has no leading or trailing spaces → TRIM(A1) = A1 → Formula returns TRUE → Entry is allowed
  • If A1 has leading or trailing spaces → TRIM(A1) ≠ A1 → Formula returns FALSE → Entry is rejected

For example:

  • If user enters "Hello" → TRIM("Hello") = "Hello" → TRUE ✓
  • If user enters " Hello" or "Hello " → TRIM will remove spaces → "Hello" ≠ " Hello" → FALSE ✗

The other options serve different purposes:

Option 2 (=LEN(A1)>10) checks if the text length exceeds 10 characters, not related to spaces.

Option 3 (=ISNUMBER(A1)) checks if the entry is a number, not related to spaces.

Option 4 (=WEEKDAY(A1)<>1) checks if a date is not Sunday, not related to spaces.

Keyboard Shortcuts

  • Left arrow: Previous question
  • Right arrow: Next question
  • S key: Jump to solution
  • Q key: Jump to question