Skip to main content

Kutools for Office — One Suite. Five Tools. Get More Done.

How to add hyphen between words in Excel?

Author Sun Last modified

In Excel, words within a cell are typically separated by spaces. However, there are situations where you might want to use hyphens to separate words instead, as illustrated in the screenshot below. For example, you may need to standardize the format of product codes, create more readable identifiers, or comply with formatting requirements for data import or export. Manually editing each cell to insert hyphens can be very time-consuming and prone to errors, especially with large datasets. This article details several practical methods to help you efficiently add hyphens between words in Excel, saving time and reducing the risk of mistakes.


Add hyphen between words by Text to Column and formula

The Text to Columns feature in Excel can split cell contents into separate columns based on delimiters such as spaces. After splitting, you can recombine the words using a formula to insert hyphens between them. This approach is useful when your data consists of consistently spaced word groups.

Applicable Scenarios: Use this solution when each cell contains words separated by spaces, and you want to add hyphens in place of those spaces. This method is straightforward if the number of words per cell is consistent. However, if your data contains varying numbers of words, additional manual adjustment of formulas may be necessary after splitting.

Tips: Before proceeding, it’s recommended to copy your original data to a backup sheet in case you need to revert later. Be aware that splitting data into multiple columns can overwrite any existing content in the columns to the right of your selection.

1. Select the list of cells where you wish to add hyphens between words, then click Data > Text to Columns. See screenshot:

2. In the first step of the Convert Text to Columns Wizard, select the Delimited option, and click Next >. In step 2, check the Space box under Delimiters. See screenshot:
A screenshot of Convert Text to Columns Wizard with Space delimiter selected

3. Click Next > again to proceed to the final step of the wizard. In the Destination box, specify where you want the split data to appear (for example, select the next empty column). See screenshot:
A screenshot of selecting a destination for split data in Text to Columns Wizard

4. Click Finish to split your data into separate columns. Then, to combine the words with hyphens, select a blank cell adjacent to your split data and enter the following formula (for example, if your words are now in columns C1 and D1): =C1&"-"&D1. Adjust the cell references as needed if there are more than two words. Apply the formula as needed for more than two split parts, for example =C1&"-"&D1&"-"&E1 if there are three words. Drag the autofill handle downwards to apply the formula to all necessary rows. See screenshot:
A screenshot of combining split data with hyphens using a formula in Excel

Precautions: After recombining, you can copy the resulting data and use Paste Values to replace the formulas with actual text if you want to further edit the contents.


Add hyphen between words by Find and Replace

The Find and Replace function in Excel provides an efficient way to replace all spaces with hyphens throughout a selected range. This solution is ideal for quickly handling large volumes of data where the only transformation required is replacing spaces with hyphen characters.

Applicable Scenarios: Use this method when you simply need to replace every space between words with a hyphen, and the contents within the cells do not require more complex manipulation. It is straightforward and works for data where words are already separated by spaces.

Tip: If you need to preserve the original data, consider copying the data to a new column before replacing spaces. Also, check for any instances of double spaces, as these will result in double hyphens after replacement unless cleaned first.

1. Select the range of cells you wish to process, then press Ctrl + H to open the Find and Replace dialog box.

2. In the dialog, under the Replace tab, type a single space (use the space bar) in the Find what field, and a hyphen (-) in the Replace with field. See screenshot:

3. Click Replace All. A dialog box will notify you how many replacements were made. Click OK to close it. As a result, all spaces between words in your selection will be replaced with hyphens. See screenshot:
A screenshot of replaced spaces with hyphens in selected data in Excel

4. Close the Find and Replace dialog.

Error reminder: Make sure your selection doesn’t contain any data where spaces should not be replaced, to prevent accidental formatting changes.


Add hyphen between words by Kutools for Excel

If your data does not contain spaces between words, such as concatenated text where each word starts with an uppercase letter (e.g., “MyExcelSheet”), traditional Find and Replace or Text to Columns methods will not work directly. In these cases, the Kutools for Excel add-in offers a highly efficient solution through its easy-to-use toolset.

Kutools for Excel offers over 300 advanced features to streamline complex tasks, boosting creativity and efficiency. Itegarate with AI capabilities, Kutools automates tasks with precision, making data management effortless. Detailed information of Kutools for Excel...         Free trial...

With Kutools for Excel, you can use the Add Text utility to insert hyphens before every uppercase character. Afterwards, the Remove by Position tool can be applied to remove any unwanted leading hyphen for each cell. This is particularly effective for handling “camel case” or “Pascal case” strings (such as converting “ThisIsAName” to “This-Is-A-Name”).

Pros: No need for complex formulas or manual edits. This approach significantly streamlines the process, especially for data with variable word lengths and structures.

Precautions: Double-check the preview in the Add Text dialog before applying changes to a large dataset. Merge results are instantly visible, and you can use Undo (Ctrl+Z) if needed.

1. Select the range of data to which you want to add hyphens, then go to Kutools > Text > Add Text. See screenshot:
A screenshot of the Add Text option on the Kutools tab on the ribbon

2. In the Add Text dialog, input a (hyphen) in the Text box. Check Only add to, and select Before uppercase letters from the dropdown. See screenshot:
A screenshot of the Add Text dialog

3. Click OK. Hyphens will be added before each uppercase character in your selection. Now, to remove an unwanted leading hyphen, click Kutools > Text > Remove by Position. See screenshot:
A screenshot of the Add Text dialog adding hyphen before uppercase letters using Kutools

4. In the Remove by Position dialog, enter 1 in the Numbers box, and select From left under Position. Confirm your choice. See screenshot:
A screenshot of the Kutools Remove by Position feature for removing leading hyphens in Excel

5. Click OK to complete. The final result will be that a hyphen appears only between words.

Troubleshooting: If the result isn't as expected, check that your selection doesn't contain extra uppercase letters where you don't want hyphens, or consider adjusting your data for cleaner results before applying the toolset.

Kutools for Excel: Over 300 handy tools at your fingertips! Enjoy permanently free AI features! Download Now!

Demo: Add Hyphen between Words using Kutools for Excel

 

Add hyphen between words or before uppercase letters by VBA macro

For Excel users comfortable with macros, a customized VBA script provides an efficient way to automatically add hyphens between words separated by spaces, or to insert hyphens before each uppercase letter when there are no separators. This method is especially valuable for repetitive processing of large worksheets or when you want to add hyphens in a more refined or conditionally controlled manner.

Applicable Scenarios: This solution is suitable when you require more flexibility, such as inserting hyphens before uppercase letters in concatenated text (e.g., “MyAccountNumber” to “My-Account-Number”), or you want the process to be automated for multiple ranges. Unlike built-in features, a macro can be tailored for special word boundary logic, batch processing, or for handling new data by running the macro again at any time.

Pros and Cons: This solution is highly repeatable and can be customized, but requires enabling macros, which may be restricted by security settings in some environments. Always save your workbook before running new macros.

Troubleshooting: If you encounter "Macros are disabled" warnings, ensure you have appropriate permissions and that your file is saved in a macro-enabled format (*.xlsm).

How to use:

1. Click Developer > Visual Basic. In the Microsoft Visual Basic for Applications window, select Insert > Module, and paste the code below into the Module panel:

Sub InsertHyphensInSelection()
    Dim rng As Range
    Dim cell As Range
    Dim txt As String
    Dim i As Integer
    Dim newTxt As String
    
    On Error Resume Next
    xTitleId = "KutoolsforExcel"
    
    If TypeName(Selection) <> "Range" Then Exit Sub
    
    Set rng = Application.InputBox("Select cells to insert hyphens:", xTitleId, Selection.Address, Type:=8)
    
    For Each cell In rng
        If Not IsEmpty(cell.Value) Then
            txt = cell.Value
            
            ' Option1: Replace spaces with hyphens
            If InStr(txt, " ") > 0 Then
                cell.Value = Replace(txt, " ", "-")
            Else
                ' Option2: Insert hyphens before uppercase letters (except the first character)
                newTxt = Left(txt, 1)
                
                For i = 2 To Len(txt)
                    If Mid(txt, i, 1) Like "[A-Z]" Then
                        newTxt = newTxt & "-" & Mid(txt, i, 1)
                    Else
                        newTxt = newTxt & Mid(txt, i, 1)
                    End If
                Next i
                
                cell.Value = newTxt
            End If
        End If
    Next cell
End Sub

2. Close the VBA editor. To run the macro, go back to Excel, select the range of cells you want to process, and press F5 key or click Run.

  • If a cell contains spaces, all spaces will be replaced by hyphens.
  • If there are no spaces (i.e., a concatenated word), a hyphen will be inserted before each uppercase letter (except the first one).

Parameter Note: The macro processes all selected cells; empty cells will be skipped.

Tips: Try the macro on a sample copy of your data to ensure you understand the transformation behavior before applying it to the original dataset.

When processing large datasets, always consider performing operations on a backup sheet or using Excel’s Undo to recover from unexpected results. If working with mixed styles of text (some cells with spaces, some with concatenated words), choose the tool or method best suited for the cell contents. The VBA macro solution is particularly flexible and can be further customized if your data has unique requirements. And if you frequently perform such formatting, automating with a macro or using Kutools for Excel can significantly boost your productivity.


Best Office Productivity Tools

🤖 Kutools AI Aide: Revolutionize data analysis based on: Intelligent Execution   |  Generate Code  |  Create Custom Formulas  |  Analyze Data and Generate Charts  |  Invoke Kutools Functions
Popular Features: Find, Highlight or Identify Duplicates   |  Delete Blank Rows   |  Combine Columns or Cells without Losing Data   |   Round without Formula ...
Super Lookup: Multiple Criteria VLookup    Multiple Value VLookup  |   VLookup Across Multiple Sheets   |   Fuzzy Lookup ....
Advanced Drop-down List: Quickly Create Drop Down List   |  Dependent Drop Down List   |  Multi-select Drop Down List ....
Column Manager: Add a Specific Number of Columns  |  Move Columns  |  Toggle Visibility Status of Hidden Columns  |  Compare Ranges & Columns ...
Featured Features: Grid Focus   |  Design View   |   Big Formula Bar    Workbook & Sheet Manager   |  Resource Library (Auto Text)   |  Date Picker   |  Combine Worksheets   |  Encrypt/Decrypt Cells    Send Emails by List   |  Super Filter   |   Special Filter (filter bold/italic/strikethrough...) ...
Top 15 Toolsets12 Text Tools (Add Text, Remove Characters, ...)   |   50+ Chart Types (Gantt Chart, ...)   |   40+ Practical Formulas (Calculate age based on birthday, ...)   |   19 Insertion Tools (Insert QR Code, Insert Picture from Path, ...)   |   12 Conversion Tools (Numbers to Words, Currency Conversion, ...)   |   7 Merge & Split Tools (Advanced Combine Rows, Split Cells, ...)   |   ... and more
Use Kutools in your preferred language – supports English, Spanish, German, French, Chinese, and 40+ others!

Supercharge Your Excel Skills with Kutools for Excel, and Experience Efficiency Like Never Before. Kutools for Excel Offers Over 300 Advanced Features to Boost Productivity and Save Time.  Click Here to Get The Feature You Need The Most...


Office Tab Brings Tabbed interface to Office, and Make Your Work Much Easier

  • Enable tabbed editing and reading in Word, Excel, PowerPoint, Publisher, Access, Visio and Project.
  • Open and create multiple documents in new tabs of the same window, rather than in new windows.
  • Increases your productivity by 50%, and reduces hundreds of mouse clicks for you every day!

All Kutools add-ins. One installer

Kutools for Office suite bundles add-ins for Excel, Word, Outlook & PowerPoint plus Office Tab Pro, which is ideal for teams working across Office apps.

Excel Word Outlook Tabs PowerPoint
  • All-in-one suite — Excel, Word, Outlook & PowerPoint add-ins + Office Tab Pro
  • One installer, one license — set up in minutes (MSI-ready)
  • Works better together — streamlined productivity across Office apps
  • 30-day full-featured trial — no registration, no credit card
  • Best value — save vs buying individual add-in