Skip to main content

Kutools for Office β€” One Suite. Five Tools. Get More Done.

How to add or insert specific characters every X characters in Excel cells

Author Xiaoyang Last modified

In Excel, adding separators like dashes or specific characters every few positions in text strings can be a tedious task if done manually. For example, inserting a dash after every four characters in multiple cells requires an efficient approach. This article provides two simple solutions: using VBA code or the Add Text utility in Kutools for Excel to insert characters at fixed intervals seamlessly.

Insert certain character every x characters into cell with VBA code

Insert certain character every x characters into cell with Kutools for Excel

An example of inserting characters every 4th position in Excel


Insert certain character every x characters into cell with VBA code

You can apply the following VBA code to insert a specific character after every four characters into cells, please do as follows:

1. Hold down the ALT + F11 keys in Excel, and it opens the Microsoft Visual Basic for Applications window.

2. Click Insert > Module, and paste the following code in the Module Window.

VBA code: Insert certain character every x characters into cell

Sub InsertCharacter()
'Updateby Extendoffice
Dim Rng As Range
Dim InputRng As Range, OutRng As Range
Dim xRow As Integer
Dim xChar As String
Dim index As Integer
Dim arr As Variant
Dim xValue As String
Dim outValue As String
Dim xNum As Integer
xTitleId = "KutoolsforExcel"
Set InputRng = Application.Selection
Set InputRng = Application.InputBox("Range :", xTitleId, InputRng.Address, Type:=8)
xRow = Application.InputBox("Number of characters :", xTitleId, Type:=1)
xChar = Application.InputBox("Specify a character :", xTitleId, Type:=2)
Set OutRng = Application.InputBox("Out put to (single cell):", xTitleId, Type:=8)
Set OutRng = OutRng.Range("A1")
xNum = 1
For Each Rng In InputRng
    xValue = Rng.Value
    outValue = ""
    For index = 1 To VBA.Len(xValue)
        If index Mod xRow = 0 And index <> VBA.Len(xValue) Then
            outValue = outValue + VBA.Mid(xValue, index, 1) + xChar
        Else
            outValue = outValue + VBA.Mid(xValue, index, 1)
        End If
    Next
    OutRng.Cells(xNum, 1).Value = outValue
    xNum = xNum + 1
Next
End Sub

3. Press F5 key to run this code. A prompt box will appear, asking you to select the data range where you want to insert a specific character into the text strings. See the screenshot below:

Prompt box to select the data range for inserting characters

4. And click OK, in the following prompt box, please enter the number that you want to insert certain character every after, see screenshot:

Prompt box to specify the number of characters after which to insert

5. Go on clicking OK, and in the followed prompt box, please enter the certain character that you want to add to the text, see screenshot:

Prompt box to enter the specific character to insert

6. Click OK button, and choose one cell where you want to output the result in the prompt box, see screenshot:

Prompt box to choose a cell for outputting results

7. Finally, click OK. The specified character will now be inserted into each text string after every four characters. See the screenshot below:

Result of inserted characters after every 4th position in Excel cells


Insert certain character every x characters into cell with Kutools for Excel

The VBA code may be challenging for Excel beginners. Here’s an easier alternative: Kutools for Excel. Using its Add Text feature, you can quickly add specific text or characters before, after, or at specific positions in cell values.

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...

1. Select the data range that you want to insert a specific character.

2. Then click Kutools > Text > Add Text, see screenshot:

Kutools for Excel Add Text option in the Excel ribbon

3. In the Add Text dialog box, specify the character you want to insert in the Text field. Under the Position section, choose Specify and enter the positions where the character should be inserted. You can preview the result in the right pane. See the screenshot below:

Preview of the Add Text utility in Kutools for Excel showing specified positions for insertion

Tips: Here I type 4,8,12 in the textbox of Specify which indicate to insert the specific text after the 4th, 8th and 12th characters of the text string.

4. Then click Ok or Apply button, the specified character has been inserted into the cell values at specific positions.

Original data before adding specified characters Arrow Final result of added characters at specific positions in Excel

Click to know more details about this Add Text utility.

Kutools for Excel - Supercharge Excel with over 300 essential tools. Enjoy permanently free AI features! Get It Now


Demo: Insert certain character every x characters into cell with Kutools for Excel

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

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