Skip to content

Instantly share code, notes, and snippets.

@stevehenderson
Created January 27, 2015 00:26
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save stevehenderson/f7253022087b0254136c to your computer and use it in GitHub Desktop.
Save stevehenderson/f7253022087b0254136c to your computer and use it in GitHub Desktop.
A VBA function to wrap a long string with newline characters
Function wrapString(incomingStr) As String
Dim pParts() As String
pParts = Split(incomingStr, " ")
Dim result As String
Dim k As Integer
For k = LBound(pParts) To UBound(pParts)
result = result & pParts(k)
If k Mod 3 = 0 Then
result = result & "\n"
Else
result = result & " "
End If
Next k
wrapString = result
End Function
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment