![]() |
Sentence extraction
Hello All
I am trying to work out a macro that will extract the last two sentences in each cell of a range for summerizing. Each cell that I am working with contains from 1 to 10 sentences. I have been trying to figure this out with out any sucess. I hope that someone out there might have a idea on how to do this. Thanks in advance Troy |
Sentence extraction
What is the pattern that defines the break? Line Feed, Period?
Die_Another_Day Viking wrote: Hello All I am trying to work out a macro that will extract the last two sentences in each cell of a range for summerizing. Each cell that I am working with contains from 1 to 10 sentences. I have been trying to figure this out with out any sucess. I hope that someone out there might have a idea on how to do this. Thanks in advance Troy |
Sentence extraction
Hi Troy,
Assumes sentences end with a dot - Option Explicit Function TwoSentences(sIn As String) As String Dim sa Dim sOut As String Dim u As Long On Error GoTo errH sa = Split(sIn, ".") 'n/a XL97 If IsArray(sa) Then u = UBound(sa) If u 0 Then If Len(sa(u)) = 0 Then u = u - 1 If Len(sa(u)) Then sOut = sa(u) & "." End If If u 0 Then If Len(sa(u - 1)) Then sOut = sa(u - 1) & "." & sOut End If Else: sOut = sIn End If End If TwoSentences = Trim(sOut) Exit Function errH: TwoSentences = CVErr(xlErrValue) End Function Regards, Peter T "Viking" wrote in message oups.com... Hello All I am trying to work out a macro that will extract the last two sentences in each cell of a range for summerizing. Each cell that I am working with contains from 1 to 10 sentences. I have been trying to figure this out with out any sucess. I hope that someone out there might have a idea on how to do this. Thanks in advance Troy |
All times are GMT +1. The time now is 10:42 AM. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com