Description The Microsoft Excel TRIM function returns a text value with the leading and trailing spaces removed. You can also use the TRIM function to remove unnecessary spaces between words in a string. The TRIM function is a built-in function in Excel that is categorized as a String/Text Function.
It can be used as a worksheet function (WS) and a VBA function (VBA) in Excel. As a worksheet function, the TRIM function can be entered as part of a formula in a cell of a worksheet. Must have programs for mac editing download. As a VBA function, you can use this function in that is entered through the Microsoft Visual Basic Editor. Example (as Worksheet Function) Let's look at some Excel TRIM function examples and explore how to use the TRIM function as a worksheet function in Microsoft Excel: Based on the Excel spreadsheet above, the following TRIM examples would return: =TRIM(A1) Result: 'Tech on the Net' =TRIM(A2) Result: '1234' =TRIM(A3) Result: 'alphabet soup' =TRIM(A4) Result: 'www.techonthenet.com' =TRIM(' apples ') Result: 'apples' Clean Up Spacing Between Words You can also use the TRIM function in Excel to remove unnecessary spaces between words in a string. The TRIM function will reduce the spacing between words down to a single space. Let's look at an example of how to use the TRIM function to clean up the spacing between words in Excel. Based on the spreadsheet above: =TRIM(A1) Result: 'techonthenet.com is a great resource for Excel' =TRIM('123 Main St.'
Open Microsoft Excel on your computer. If you’re using Windows, type excel into the search bar and click Microsoft Excel in the results. If you’re using a Mac, you’ll find Excel in the Applications folder. Use this method if you want to include cells with numbers in formulas without the numbers being calculated. TRIM Formula in Excel. The TRIM formula in Excel is denoted =TRIM(text). This formula will remove any spaces entered before and after the text entered in the cell. For example, if A2 includes the name ' Steve Peterson' with unwanted spaces before the first name, =TRIM(A2) would return 'Steve Peterson' with no spaces in a new cell.
) Result: '123 Main St.' In these two examples, the TRIM function will reduce the spacing between words down to a single space. This is a great way to clean up data that may not be formatted properly with unnecessary extra spaces.