Data Analysis

Spanish TRIM Formula: Use ESPACIOS

Marc SeanOctober 13, 20266 min read
=ESPACIOS(A1)

It removes leading and trailing ordinary spaces, then reduces repeated ordinary spaces between words to one. If your spreadsheet uses English function names, use =TRIM(A1) instead.

However, ESPACIOS doesn't remove every whitespace character. To remove non-breaking spaces, replace character 160 before applying the function:

=ESPACIOS(SUSTITUIR(A1;CARACTER(160);" "))

Depending on your regional configuration, the formula may require commas instead of semicolons.

ESPACIOS syntax in Excel and Google Sheets

The Spanish syntax takes one text argument:

=ESPACIOS(texto)

You can write the text directly inside the formula:

=ESPACIOS("  Informe   mensual  ")

Alternatively, use a cell reference:

=ESPACIOS(A1)

The English equivalent is:

=TRIM(A1)

Google documents TRIM as removing leading, trailing, and repeated spaces. Microsoft describes the same behavior in its Excel TRIM documentation.

Reproducible example: remove extra spaces

Create a sheet named Datos. In Datos!A1, enter:

="  Informe   mensual  "

This formula produces text containing:

  • 2 leading ordinary spaces
  • 3 spaces between the words
  • 2 trailing ordinary spaces

Next, enter this formula in Datos!B1:

=ESPACIOS(A1)

The expected result is:

Informe mensual

Use these checks to verify the result:

=LARGO(A1)

Expected result: 21

=LARGO(B1)

Expected result: 15

The 4 outside spaces are removed, while the 3 internal spaces become 1.

For imported account, vendor, or cost-center labels, keep the original text in column A and use column B as the cleaned matching key. This structure preserves the source value while providing consistent text for lookups and aggregations.

Check blank and whitespace-only cells

Evaluate these cases separately by changing Datos!A1 while keeping =ESPACIOS(A1) in Datos!B1.

Value or formula in Datos!A1Expected display in Datos!B1
=" Informe mensual "Informe mensual
="Informe mensual"Informe mensual
Completely empty cellBlank
=" "Blank

When A1 is empty or contains only ordinary spaces, B1 displays an empty string. Because the cell still contains a formula, however, this check returns FALSO:

=ESBLANCO(B1)

With English function names, =ISBLANK(B1) returns FALSE.

That distinction matters when downstream formulas test for physically empty cells rather than empty displayed results.

Choose between ESPACIOS and TRIM

A Spanish spreadsheet locale doesn't always mean the workbook uses Spanish function names.

In Google Sheets, locale and function language are separate settings. A workbook can use Spanish date, number, and currency formats while Always use English function names remains enabled. Google describes these options in its spreadsheet locale and calculation settings.

Check the workbook before converting formulas:

  • If entering =ESP suggests ESPACIOS, use Spanish names.
  • If entering =TRI suggests TRIM, use English names.
  • If ESPACIOS produces a name error, review the function-language setting.

In Excel, localized function names generally follow the application’s display language. Regional settings also determine whether formulas with multiple arguments use commas or semicolons.

Since the basic formula has only one argument, separators don't affect it:

=ESPACIOS(A1)

For formulas with several arguments, use the separator accepted by the workbook:

ConfigurationFormula
Spanish names with semicolons=ESPACIOS(SUSTITUIR(A1;CARACTER(160);" "))
Spanish names with commas=ESPACIOS(SUSTITUIR(A1,CARACTER(160)," "))
English names with commas=TRIM(SUBSTITUTE(A1,CHAR(160)," "))

Remove non-breaking spaces with SUSTITUIR

ESPACIOS handles ordinary U+0020 spaces but doesn't remove the U+00A0 non-breaking space, represented by decimal character code 160. Although the two characters usually look the same, Google and Microsoft document this limitation in their respective TRIM guidance.

To reproduce the issue, replace Datos!A1 with:

="Informe"&CARACTER(160)&CARACTER(160)&"mensual"

The existing =ESPACIOS(A1) formula in B1 leaves the non-breaking spaces in place.

Now enter this formula in Datos!C1:

=ESPACIOS(SUSTITUIR(A1;CARACTER(160);" "))

The expected result is:

Informe mensual

The calculation works in 2 stages:

  1. SUSTITUIR replaces each U+00A0 character with an ordinary space.
  2. ESPACIOS reduces the resulting consecutive spaces to one.

To check whether A1 contains at least one character 160, use:

=LARGO(A1)<>LARGO(SUSTITUIR(A1;CARACTER(160);""))

For the example above, the expected result is VERDADERO.

The comma-separated version is:

=LARGO(A1)<>LARGO(SUSTITUIR(A1,CARACTER(160),""))

For an English-function workbook, use:

=TRIM(SUBSTITUTE(A1,CHAR(160)," "))

This replacement targets U+00A0 specifically. If the text contains other invisible Unicode characters, you'll need to diagnose and replace them separately.

Clean tabs, line breaks, and non-breaking spaces

ESPACIOS handles ordinary spaces, while LIMPIAR removes supported nonprinting control characters such as tabs and line feeds. For imported text that may contain both control characters and U+00A0, use:

=ESPACIOS(LIMPIAR(SUSTITUIR(A1;CARACTER(160);" ")))

The English-function equivalent is:

=TRIM(CLEAN(SUBSTITUTE(A1,CHAR(160)," ")))

This formula doesn't remove every possible invisible Unicode character. If unwanted characters remain, identify the specific character before adding another replacement.

For conditional cleanup across a Google Sheets range, see ARRAYFORMULA with IF for finance data.

Preserve identifiers before cleaning them

Because ESPACIOS reduces repeated internal spaces, confirm that spacing isn't meaningful before applying it to:

  • Fixed-width identifiers
  • Product, account, or cost-center codes
  • Labels that distinguish one space from several
  • Text whose alignment is encoded with spaces

A staging structure keeps the transformation auditable:

ColumnContentsPurpose
ARaw source textPreserved import value
BCleaned textLookup and aggregation key
CAmount or other source valueFinancial data

Before pointing SUMAR.SI.CONJUNTO, BUSCARX, or their English equivalents at column B, review any labels that merge after cleaning. Two visually similar source values may represent the same account, but they may also be intentionally distinct identifiers.

How ModelMonkey can help with inconsistent text

ModelMonkey is an AI assistant for spreadsheet work in Google Sheets and Excel. For this cleanup task, you can ask it to inspect a specified text range, search for inconsistent labels, and help add a cleaned helper column while preserving the raw import.

For example, use this task prompt:

Inspect Datos!A2:A500 for leading, trailing, repeated, or non-breaking spaces. Keep column A unchanged, propose a locale-compatible cleaning formula in column B, and verify the affected range for formula errors.

ModelMonkey can read spreadsheet context and help write or organize the relevant cells. Before using the new key in financial summaries, review the formulas and cleaned labels, along with any preview available in the workflow.

Install ModelMonkey to inspect and clean a spreadsheet text range.

Frequently Asked Questions