Here's an example of code that will do this:
Option Explicit
Public Sub main() Dim strCellText As String Dim strCellTextLines As New Collection Dim vv As Variant strCellText = ThisDocument.Tables(1).Cell(1, 1).Range.Text Set strCellTextLines = ParseLines(strCellText) MsgBox "Lines of text found = " & CStr(strCellTextLines.Count) For Each vv In strCellTextLines MsgBox vv Next vv Set strCellTextLines = Nothing End Sub
Private Function ParseLines(tStr As String) As Collection Dim tColl As New Collection, tptr As Integer, tlastptr As Integer, tCurrStr As String tlastptr = 1
With tColl Do tptr = InStr(tlastptr, tStr, Chr(13)) If tptr = 0 Then Exit Do
tCurrStr = Mid(tStr, tlastptr, tptr - tlastptr) tColl.Add tCurrStr
tlastptr = tptr + 1 Loop End With
Set ParseLines = tColl End Function
Feel free to email if you've got questions.
|