I have several cells that I am trying to reformat.
The data comes in with strings of spaces and I need to find a way to replace any string of 2 or more spaces (some cells have strings of 30) with 1 alt+enter.
So if I have a string in 1 cell that says
I want it to look like:
all within the same cell.
(Most of the cells are already formatted with the alt+enter to separate the data, but I need to fix the ones that aren't. I have another macro that searches for the alt+enter to perform some additional reformatting.)
I found this function online that I think does what I want, but I am new to VBA and am not familiar with how functions work or where to put them.
Function SpacesLF(strInput As String) As String
With CreateObject("vbscript.regexp")
.Pattern = " {2,}"
.Global = True
SpacesLF = .Replace(strInput, vbLf)
End With
End Function
I would appreciate any help you could give.
Thanks so much!
Bookmarks