Results 1 to 20 of 22

Thread: Convert Text to cells Sentences by Punctuation Marks

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #12
    VBAX Regular
    Joined
    Apr 2016
    Posts
    35
    Location
    Quote Originally Posted by p45cal View Post
    From a file:
    Sub blah()
    Set Destn = ActiveSheet.Cells(1)
    Set ts = CreateObject("Scripting.FileSystemObject").opentextfile("C:\Users\Public\Documents\dummy sentences.txt")
    bt = Application.Trim(ts.readall)
    ts.Close
    at = Replace(Replace(Replace(Replace(bt, "...", "…¬"), ".", ".¬"), "?", "?¬"), "!", "!¬")
    at2 = Split(at, "¬")
    For i = 0 To UBound(at2)
      at2(i) = Application.Trim(at2(i))
      at2(i) = Replace(at2(i), "…", "...")    'optional to replace an ellipsis with 3 dots.
      If Len(at2(i)) = 0 Then at2(i) = "¬"
    Next i
    at3 = Filter(at2, "¬", False)
    Destn.Resize(UBound(at3) + 1).Value = Application.Transpose(at3)
    'Set Destn = Destn.Offset(UBound(at3))
    End Sub
    There's only one line in the text file you supplied so I don't know if it will work if there are more lines.
    Hello this code working well with small datas. But its giving error with big datas. i share another text file for example for big datas. İ hope you can help me. Thank you.
    Attached Files Attached Files

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •