How to clean up names in Google Sheets
Names typed into forms come back as JUAN PEREZ, maria lopez or Ana de la Cruz with stray spaces. They look messy in mail merges and hide duplicates.
Step 1: remove extra spaces
=TRIM(A2) removes leading, trailing and repeated spaces. Text pasted from the web may contain non-breaking spaces; use =TRIM(SUBSTITUTE(A2,CHAR(160)," ")).
Step 2: fix capitalization
=PROPER(TRIM(A2)) turns JUAN PEREZ into Juan Perez. It keeps accents (josé → José).
Step 3: keep particles lowercase
PROPER writes Ana De La Cruz. To keep de, del, la, van, von lowercase, chain one REGEXREPLACE per particle: =REGEXREPLACE(REGEXREPLACE(REGEXREPLACE(PROPER(TRIM(A2))," De "," de ")," Del "," del ")," La "," la ").
Step 4: split first and last name
=SPLIT(B2," ") splits on every space, which breaks compound surnames. A safer split for "first name + the rest": =REGEXEXTRACT(B2,"^\S+") and =REGEXEXTRACT(B2,"^\S+\s+(.*)$").
Watch out for
Names like McDonald, O'Brien or brand names written in capitals on purpose. Review a sample before replacing the original column.
DataTools AI