SUBSTITUTE & LEN Text Cleanup in Excel & Google Sheets

Swap unwanted characters or line breaks cleanly with SUBSTITUTE and validate text or code lengths with LEN before importing or matching data.

1. Replace Characters or Line Breaks With SUBSTITUTE

Use SUBSTITUTE(text, old_text, new_text) to swap specific characters—such as replacing hyphens with spaces or stripping line breaks (CHAR(10)) from pasted cells:

=SUBSTITUTE(A2, CHAR(10), ", ")

2. Check Cell Length With LEN

Use LEN(cell) to count total characters (including spaces) when verifying ID lengths, SKU codes, or text limits:

=LEN(A2)

Worked Example: SUBSTITUTE & LEN

Cell A2 (Input) =SUBSTITUTE(A2, "-", "") =LEN(A2)
INV-1001 INV1001 8
SKU-45 SKU45 6

Tips & Error Prevention

Editorial & Accuracy Note: Tested across Microsoft Excel and Google Sheets with worked sample inputs and outputs. Part of the Know Unlimited Excel & Google Sheets Hub.