Thread: [Solved] Cleaning_texts
View Single Post
 
Old 12-30-2021, 10:56 PM
Bikram Bikram is offline Windows 10 Office 2007
Advanced Beginner
 
Join Date: Jul 2021
Location: Nepal
Posts: 94
Bikram is on a distinguished road
Default

Thank you sir. It did a great job. But it removed all paragraph breaks what i need to do now is find full stop "." followed by "[a-z]." and insert a paragraphbreak before the text.
Code:
Sub Insertpara()
Dim str As String
Dim sbstr As String
Dim ix As Long
Dim times As Variant
Dim sblen As Long
Dim i As Integer
 Set rng = Selection.Range
    str = Selection.Range.Text
    sbstr = "." ' I checked the code using a full stop but i want to find "?." to find any character followed by full stop
    sublen = Len(sbstr)
    ix = 1
    occurences = -1
    Do
        times = times + 1
        idx = InStr(ix, str, substr, vbBinaryCompare) + sblen
      
        Selection.Range.Characters(ix).InsertAfter (Chr(13))
               
       
    Loop While ix > sblen
End Sub
I gathered and modified the above code that i copy and pasted from a website it does work fine for the first times(occurences) but from the second time, it is not accurate. Can you please help to modify the code as per my requirement? Thanks in advance sir.
Reply With Quote