Use VBA Code to Remove Extra Spaces in a Cell in Excel. But the problem is this function removes all the spaces including the space in between words. 1. A dialog box will pop up. It has 3 columns that represent a persons information. In the end, press ENTER. These columns are Name, Zip Code, and Address. Finally, we can see in the Salary Using SUBSTITUTE Function column, that there are no spaces between the numbers of salary. Use the SUBSTITUTE function to remove all spaces or non-breaking spaces.