<\/figure>\n\n\n\nStep 7<\/strong> \u2013 Select Cell B6 and copy the formula to Cell C6 by dragging the Fill Handle across to Cell C6:<\/p>\n\n\n\n <\/figure>\n\n\n\nYou will notice that the SUM function has returned the correct value because the values in the range C2:C5 are numbers.<\/p>\n\n\n\n
Explanation of the Formula<\/h3>\n\n\n\n=VALUE(TRIM(A2))<\/code><\/pre>\n\n\n\n\nTRIM(A2) stripped the numeric value of all extra spaces but converted it to a text string.<\/li>\n\n\n\n In VALUE(TRIM(A2)) the VALUE function converted the text string to a numeric value.<\/li>\n<\/ol>\n\n\n\nMethod 4 \u2013 Use the combination of the SUBSTITUTE function and TRIM function<\/h2>\n\n\n\n The TRIM function<\/strong> removes all spaces from a text string except for single spaces between words. It deletes all leading, trailing, and in-between spaces except for single-space characters between words.<\/p>\n\n\n\nIt was designed to trim only the ASCII space character<\/strong> which has a code value of 32.<\/p>\n\n\n\nIn the Unicode character set, however, there is an additional space character called the nonbreaking space character<\/strong>. This character is usually used on web pages and has a Unicode value of 160.<\/p>\n\n\n\nThis means that the TRIM function<\/strong> which was designed to handle only CHAR(32)<\/strong> space characters and cannot handle CHAR(160)<\/strong> space characters. To handle this kind of space, we will have to employ the SUBSTITUTE function<\/strong> to find CHAR(160)<\/strong> space characters and replace them with CHAR(32)<\/strong> space characters so that the TRIM function can fix them.<\/p>\n\n\n\nWe will use the following example dataset to explain how nonbreaking space characters can be removed from data:<\/p>\n\n\n\n <\/figure>\n\n\n\nIn this dataset, the First Name and Last Name columns have invisible nonbreaking space characters. They however become apparent when we combine the names in Column C<\/strong>.<\/p>\n\n\n\nStep 1<\/strong> – Select Cell C2<\/strong> and type in the formula =A2&” “&B2 as follows:<\/p>\n\n\n\n <\/figure>\n\n\n\nStep 2<\/strong> \u2013 Press the Enter key and drag down the Fill Handle to copy the formula down the column:<\/p>\n\n\n\n <\/figure>\n\n\n\nYou notice that the full names in Column C<\/strong> have extra spaces. This is because of the nonbreaking character spaces in the data in Column A<\/strong> and Column B<\/strong>.<\/p>\n\n\n\nLet\u2019s see if the TRIM function will remove these extra spaces.<\/p>\n\n\n\n
Step 3<\/strong> \u2013 Select Cell D2<\/strong> and type in the formula =TRIM(A2&” “&B2) as follows:<\/p>\n\n\n\n <\/figure>\n\n\n\nStep 4<\/strong> \u2013 Press the Enter key and drag down the Fill Handle to copy the formula down the column. The result will appear as follows:<\/p>\n\n\n\n <\/figure>\n\n\n\nYou will notice that the TRIM function has not been able to remove the nonbreaking space characters from the data.<\/p>\n\n\n\n
To remove these nonbreaking space characters we have to use the combination of the SUBSTITUTE function and TRIM function.<\/p>\n\n\n\n
Step 5<\/strong> \u2013 Select Cell E2 and type in the formula =TRIM(SUBSTITUTE(A2,CHAR(160),CHAR(32)))&” “&TRIM(SUBSTITUTE(B2,CHAR(160),CHAR(32))) as follows:<\/p>\n\n\n\n <\/figure>\n\n\n\nStep 6<\/strong> \u2013 Press the Enter key and drag down the Fill Handle to copy the formula down the column. The result will appear as follows:<\/p>\n\n\n\n <\/figure>\n\n\n\nNotice that all the extra spaces in Column E<\/strong> have been removed.<\/p>\n\n\n\n