As much as we like to work with clean/structured data only, it’s certainly not the case when importing data from external sources. Sometimes, unwanted characters like commas appear across all the text and we end up with texts like “Jackie, Reacher” instead of “Jackie Reacher” or similar.
Likewise, Excel uses commas as the thousands separator between the numbers (like 1,000) to make them more readable. However, commas in something like a student ID or employee ID are rather inappropriate or unnecessary.
Nonetheless, we have compiled a list of built-in methods and functions to quickly get rid of them in various scenarios. Keep reading to learn more in detail.
Using the Find and Replace Tool
Usually, we use the Find and Replace tool to replace a particular text/character with a different one.
But, in this particular case, you can replace the comma with a blank character as well.
- Select the row, column, or cell range depending on where you want to replace the commas.
- Then, press Ctrl + H.
- On the Find and Replace window, type
,next to Find what field.
- Next to Replace with field, enter another character you want instead of the comma Otherwise, leave it empty.
- Choose one of the following options next to the Search field.
- By Columns: To replace the comma in column (s)
- By Rows: To replace the comma in row (s)
- Click Find Next to go through each cell where the comma will be replaced/ removed.
- Click Replace All.
Using Power Query
The Power Query has a built-in feature similar to the Find and Replace tool, which can remove comma characters.
The Power Query also provides a similar feature like the Find and Replace tool to remove comma characters.
However, it provides additional options for several other data-cleaning operations like splitting parts of a text before or after a comma. Also, it allows an undo option to revert to the previous steps whenever required.
But, note that loading a huge dataset into Power Query can take some time. In that case, the Find and Replace function is a much quicker and more appropriate method.
- Select all cells containing your data.
- Under the Data tab, click From Table/ Range. Look for it inside the Get & Transform Data.
- Enable the My table has headers if your data has headers.
- On the Power Query Editor window, click the column header which contains the unwanted comma characters. To select multiple columns, press the Ctrl key while clicking them.
- Then, select the Home tab and click Replace Values.
- On the next prompt, type a comma character under the Value to Find section. Leave the Replace with field empty unless you want to replace the comma characters with others like spaces, dashes, etc.
- Click OK.
- To undo a step, click the cross icon next to it under the Applied Steps section. You can find it at the right side.
- When done, click Close & Load > Close & Load To.
- Choose the preferred destination to load the final output.
Using Custom Formatting
Whenever a number is using an accounting number format, Excel displays it with a comma, such as $1,000.00, €1,000.00, or similar.
Also, Excel uses commas, by default, as the thousands separators resulting in a number like 1,000 or 1,000.00.
Whichever your case is, you can change and use custom formatting to avoid commas in numbers.
- Select the cell (s) containing commas.
- Press Ctrl + 1.
- Select the Number tab.
- Then, choose Number under the Category section.
- Uncheck the Use 1000 Separator (,) checkbox.
- Alternatively, select Custom under the Category section. Then, choose a different formatting under the Type section such as 0, #,##0, #,##0.00, etc.
- When done, click OK.
To change the comma character as the default thousands separator for the whole Excel application,
- Open the Excel app.
- Then, select File > Options.
- Next, select Advanced from the sidebar.
- On the right pane, scroll down to the Editing options section.
- Uncheck the Use system separators checkbox and replace the comma with the preferred thousands separator.
Using the SUBSTITUTE Function
As the name suggests, the Substitute function substitutes a particular value with another specified value. Using it, you can remove commas or replace them with other characters like a -,+, or any other character.
=SUBSTITUTE(text, old_text, new_text)
- text: Cell or cell reference of the text containing a specific character like a comma
- old_text: The character you want to replace (comma in our case)
- new_text: A character that will replace the old_text character
- Create a helper column to hold values after removing commas.
- Type the following formula under the new column. Replace
A2:A10with the cell range which contains the text values with commas in your dataset.
- Press Enter.
Using Flash Fill
This method works particularly well given that texts with unwanted commas exist within the same column and follow the same pattern.
The good part is you don’t have to use any formula whatsoever. Also, it doesn’t necessarily remove every comma unless you want to. So, you can remove comma (s) existing at a particular position of a text value.
For instance, the text “Alexandria, VA 22304, USA” contains two commas. But, we only want to remove the first comma, giving us the result “Alexandria VA 22304, USA.”
- Create a helper column to store text values without commas.
- Manually type the text value without the comma (s) under the new column and press Enter.
- Start typing the next text without the comma and as soon as Excel autocompletes other cells, press Enter.