Skip to main content

TRIM

Removes all spaces from a text string except for single spaces between words.

Syntax​

expression.TRIM(arg1);

expression - A variable that represents an ApiWorksheetFunction class.

Parameters​

NameRequired/OptionalData typeDefaultDescription
arg1RequiredApiRange | ApiName | stringThe text from which the spaces will be removed.

Returns​

string

Example​

Remove extra spaces from text, keeping single spaces between words in a spreadsheet.

// How do I clean up spacing in text within a spreadsheet?

// Delete unnecessary spaces from a text string in a spreadsheet.

let worksheet = Api.GetActiveSheet();
let func = Api.WorksheetFunction;
worksheet.GetRange("A1").SetValue(func.TRIM(" Online Office"));