Site icon DW Faisalabad

Add Space Between Characters Or Every Digit In Excel

Add Space Between Characters Or Every Digit In Excel

In this article we will discuss about how to Add Space Between Characters Or Every Digit In Excel, we will learn this step by step with VBA Codes. Supposing you have a list of text strings or numbers, for adding space between characters or every digits, what can you do? The following methods can help you solve this problem.

You can use the following user-defined function to add space between characters or every digits in Excel.

  1. Open MS Excel sheet where and want to apply this formula
  2. Press Alt + F11 keys simultaneously to open the Microsoft Visual Basic for Applications window.
  3. In the Microsoft Visual Basic for Application window, click Insert > Module.
  4. Then copy and paste the following code into the Module window.
VBA Code: Add Space Between Characters Or Every Digits
Function AddSpace(Str As String) As String
Dim i As Long
For i = 1 To Len(Str)
AddSpace = AddSpace & Mid(Str, i, 1) & ” ”
Next i
AddSpace = Trim(AddSpace)
End Function
  1. Press Alt + Q keys to close the Microsoft Visual Basic for Applications window and get back to the Excel window.
  2. Select a blank cell, enter formula =AddSpace(B2) into the Formula Bar, then press the Enter key.

In this case, you can see spaces are added between characters of cell B2.

Note: For adding space between every digits, please change the cell reference in the formula to the one with numbers as you need.

Exit mobile version