See all How-To Articles

Replace Space With Underscore in Excel & Google Sheets

This tutorial demonstrates how to replace a space character with an underscore in Excel and Google Sheets.

 

replace space with underscore initial data

 

Replace Space With Underscore

In Excel, you can easily replace spaces with underscores. Say you have product names with product and manufacturer separated by spaces (as shown below), and you want to separate them by underscores instead.

 

replace space with underscore initial data

 

  1. Select the range of cells where you want to replace spaces (here, B2:B7), and in the Ribbon, go to Home > Find & Select > Replace (or use the keyboard shortcut CTRL + H).

 

replace space with underscore 1

 

  1. In the Find and Replace window, (1) type a space in Find what box and (2) underscore (_) in the Replace with box. Then (3) click on Replace All.

 

replace space with underscore 2

 

  1. A message pops up with the total number of changes made; just press OK.

 

replace space with underscore 3

 

  1. Close the Find and Replace window by clicking on the Close button.

 

replace space with underscore 4

 

As a result, all spaces in the selected cells are replaced by underscores.

 

replace space with underscore final data

 

Replace Space With Underscore in Google Sheets

You can replace spaces with underscores in Google Sheets in a very similar way.

  1. Select the range of cells where you want to replace spaces (B2:B7), and in the Menu, go to Edit > Find and replace (or use the keyboard shortcut CTRL + H).

 

google sheets replace space with underscore

 

  1. In the pop-up window, (1) enter space in the Find box and (2) underscore (_) in the Replace with box. The, (3) click Replace All and (4) Done.

 

google sheets replace space with underscore 2

 

The result is the same as in Excel: All spaces in the selected range are converted to underscores.