+ Reply to Thread
Results 1 to 5 of 5

Modifying VBA to exclude a given string

  1. #1
    Forum Contributor
    Join Date
    01-18-2013
    Location
    London
    MS-Off Ver
    Excel 2003
    Posts
    328

    Modifying VBA to exclude a given string

    I use this code to find all words composed solely of two or more capital letters and remove them ;

    Please Login or Register  to view this content.
    It works fine in tidying up my text. Unfortunately , it removes a very commonly used expression the the shape of 'OK'.

    Can someone suggest a modification to my code above so that it leaves any occurrences of 'OK' in place?

    Grateful for any advice.

    Using Excel , Word and Access 2003 - March 2022

  2. #2
    Forum Guru macropod's Avatar
    Join Date
    12-22-2011
    Location
    Canberra, Australia
    MS-Off Ver
    Word, Excel & Powerpoint 2003 & 2010
    Posts
    3,646

    Re: Modifying VBA to exclude a given string

    For example:
    Please Login or Register  to view this content.
    Last edited by macropod; 05-13-2021 at 08:35 PM.
    Cheers,
    Paul Edstein
    [Fmr MS MVP - Word]

  3. #3
    Forum Contributor
    Join Date
    01-18-2013
    Location
    London
    MS-Off Ver
    Excel 2003
    Posts
    328

    Re: Modifying VBA to exclude a given string

    OK thanks - that's fixed it. It removes words with only two capitals , but leaves 'OK' and the others in the specified string in place.

    BTW - I've discovered the next obstacle is where 'OK' is used as a sentence within itself.

    For example , where the text has

    OK.
    OK-
    OK,
    OK!
    OK?

    In these cases , the VBA is deleting them because of the third character of course , when really it should leave them in place..!

  4. #4
    Forum Guru macropod's Avatar
    Join Date
    12-22-2011
    Location
    Canberra, Australia
    MS-Off Ver
    Word, Excel & Powerpoint 2003 & 2010
    Posts
    3,646

    Re: Modifying VBA to exclude a given string

    I've revised the code. The revisions mean text like OK followed by a space will be deleted along with the space (which is what one would ordinarily want).

  5. #5
    Forum Contributor
    Join Date
    01-18-2013
    Location
    London
    MS-Off Ver
    Excel 2003
    Posts
    328

    Re: Modifying VBA to exclude a given string

    Very good. Thanks for your help - much appreciated.


+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. [SOLVED] Extract 5th string onwards but exclude 6th string onwards if found a specificlist of words
    By suchetherrah in forum Excel Formulas & Functions
    Replies: 10
    Last Post: 03-07-2016, 03:48 AM
  2. [SOLVED] Formula to exclude anything before first appearing number in a string
    By chriskay in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 08-26-2014, 09:49 AM
  3. Conditional format: mark cells with 1 text string & exclude cells with another string
    By KArnoldColumbia in forum Excel Formulas & Functions
    Replies: 4
    Last Post: 11-15-2013, 01:43 AM
  4. [SOLVED] How to Exclude text in string in a single cell
    By leopoldc in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 10-28-2013, 07:01 AM
  5. Modifying String
    By JCL622 in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 05-07-2012, 03:33 PM
  6. Modifying macro to search for string instead of matching value.
    By Folshot in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 05-16-2011, 07:16 PM
  7. String of dates to exclude weekends AND holidays
    By FEI7774 in forum Excel Formulas & Functions
    Replies: 1
    Last Post: 06-01-2009, 06:19 PM

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