+ Reply to Thread
Results 1 to 6 of 6

Removing ".", "?" or "!" from last word of sentence and replacing it later in vba.

Hybrid View

  1. #1
    Registered User
    Join Date
    12-07-2012
    Location
    London, England
    MS-Off Ver
    Office 2010
    Posts
    81

    Removing ".", "?" or "!" from last word of sentence and replacing it later in vba.

    Hi,

    I have a routine that takes a sentence and uses Split to separate the words for processing.

    It works fine, except for the last word, because this will have a period or whatever, and so a word look-up will fail.

    I need to get the last word, remove the period (and remember it).

    Then I need to process all the words (that part works fine), and put the ending back.

    Whatever I try I gt syntax errors when I try to address the last element (last word) in the Split array to alter the word.

    Any help would be much appreciated.

  2. #2
    Forum Expert
    Join Date
    07-16-2010
    Location
    Northumberland, UK
    MS-Off Ver
    Excel 2007 (home), Excel 2010 (work)
    Posts
    3,054

    Re: Removing ".", "?" or "!" from last word of sentence and replacing it later in vba.

    Can you post a workbook, or at least the code you're using?

  3. #3
    Valued Forum Contributor
    Join Date
    02-12-2011
    Location
    The Netherlands
    MS-Off Ver
    365
    Posts
    860

    Re: Removing ".", "?" or "!" from last word of sentence and replacing it later in vba.

    The last word in the 'Split routine'.
    sq = Split(Range("A1"))
    Lastword = sq(UBound(sq))
    Last edited by HSV; 01-15-2013 at 06:17 PM. Reason: ))))))
    Harry.

  4. #4
    Forum Expert
    Join Date
    07-16-2010
    Location
    Northumberland, UK
    MS-Off Ver
    Excel 2007 (home), Excel 2010 (work)
    Posts
    3,054

    Re: Removing ".", "?" or "!" from last word of sentence and replacing it later in vba.

    Works better if you close off your brackets

    Lastword = sq(UBound(sq))

  5. #5
    Valued Forum Contributor
    Join Date
    02-12-2011
    Location
    The Netherlands
    MS-Off Ver
    365
    Posts
    860

    Re: Removing ".", "?" or "!" from last word of sentence and replacing it later in vba.

    Maybe I was a second after you in my edit.

  6. #6
    Registered User
    Join Date
    12-07-2012
    Location
    London, England
    MS-Off Ver
    Office 2010
    Posts
    81

    Re: Removing ".", "?" or "!" from last word of sentence and replacing it later in vba.

    That worked, HSV. Thanks.

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

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

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1