Skip to content
  • There are no suggestions because the search field is empty.

Adding Spaces Between Words in the Employee CSV Import/Export File

This article walks through how to inject spaces between words in the Employee CSV sheet using Excel.

Here are some examples of what this process will accomplish:

  • "HumanResources" instead of "Human Resources"
  • "VicePresident" instead of "Vice President"
  1. Open the Employee CSV file you wish to modify in Excel.
  2. Hold down ALT + F11 keys to open the Microsoft Visual Basic for Applications window.
  3. Click Insert > Module, and paste the following code in the Module window.
    VBA code: Insert spaces before capital letters

    Function AddSpaces(pValue As String) As String

    'Update 20140723

    Dim xOut As String

    xOut = VBA.Left(pValue, 1)

    For i = 2 To VBA.Len(pValue)

       xAsc = VBA.Asc(VBA.Mid(pValue, i, 1))

       If xAsc >= 65 And xAsc <= 90 Then

          xOut = xOut & " " & VBA.Mid(pValue, i, 1)

       Else

          xOut = xOut & VBA.Mid(pValue, i, 1)

       End If

    Next

    AddSpaces = xOut

    End Function

  4. Save and close this code.
  5. Enter the "formula =addspaces(A1)" into a blank cell beside your data. The screenshot below is an example.
    SHQEFd1uJCI_ZU3yNHy8H1uXWZ_0iC4m_A
  6. Highlight the range to which you want to apply the formula. The spacing will update, as seen below.
    OUKF4BuPlfkZ1L8AfSclpB-HKfof4V03eg