hey guys, for my job we have a bunch of account info (on separate lines) with names for each account consolidated into 1 cell (example: A1 = ANNE ARUNDEL COUNTY RETIREMENT SYSTEM).
<tbody>
</tbody><colgroup><col></colgroup>
were doing a data merge and the field in our system only fits 35 characters. we would like to split the names of these accounts (up to 35 characters) but not split the names in the middle. right now I have some VBA code that does that trick except it's putting the characters past 35 on the line below. I would like to fix it so that it just moves it to the next cell to the left. Sub splitup35() Dim c As Range, z As String, tmp As String, j As Long, k As Integer k = -1 For Each c In Range("A1", Range("A65536").End(xlUp)) z = Trim(c) Do tmp = Trim(Left(z, 35)) j = 35 If Right(tmp, 1) <> " " And (Mid(z, 36, 1) <> " " And Len(z) > 35) And Right(tmp, 1) <> "." And Right(tmp, 1) <> "," Then j = InStrRev(tmp, " ") tmp = Left(tmp, j) If tmp <> "" Then Range("B65536").End(xlUp).Offset(1 + k, 0) = tmp k = 0 z = Trim(Mid(z, j + 1)) Loop Until tmp = "" k = 1 Next End Sub |
<tbody>
</tbody><colgroup><col></colgroup>