CodeSteps

Python, C, C++, C#, PowerShell, Android, Visual C++, Java ...

Microsoft Excel – Text Functions – TRIM and REPT formulas

When dealing with data, Microsoft Excel provides a lot of useful Text functions. We will discuss another set of Text functions; TRIM and REPT in this Article.

The TRIM formula

This function is used to remove all the leading and trailing spaces in the given text. We can pass the text directly to the function or we can pass the cell reference.

It also removes all the unnecessary spaces between the words in the given text. It will keep a single space, between the words.

The Syntax of the function is:

=TRIM(text)

where text is the given text.

FormulaResult
=TRIM(”  Hello, World!  “)Hello, World!
=TRIM(“Remove too                           many spaces”)Remove too many spaces

The REPT formula

REPT function is used to repeat the text a given number of times.

The Syntax of the function is:

=REPT(text, repeat_times)

text is the given text and repeat_times to instruct the number of times the text to repeat.

FormulaResult
=REPT(“Hello! “, 2)Hello! Hello!
=REPT(“Hello!”, 0)

The value entered intorepeat_times should be a valid value. Otherwise, Excel throws the #VALUE! Error.

We discuss more topics as we go.

🙂 Sahida

Microsoft Excel – Text Functions – TRIM and REPT formulas

Leave a Reply

Your email address will not be published. Required fields are marked *

Scroll to top