+ Reply to Thread
Results 1 to 3 of 3

rewriting a cell's contents within a range of cells

  1. #1
    Registered User
    Join Date
    02-24-2011
    Location
    Somewhere, Ohio
    MS-Off Ver
    Excel 2007
    Posts
    20

    rewriting a cell's contents within a range of cells

    I am trying to create a macro that will scan a range of cells
    and replace the (text) contents of the cell based on keywords
    within the cell. For example, if a cell contains:

    APPROVED MED WAIVER INSPECT & ENLIST TEAM GAMBIT

    i want it to replace this string with INSPECT & ENLIST

    The following code will scan through the correct range of cells.
    it includes the key words I want to search for. Also, it rewrites
    the cell contents BUT it is only putting the & in the cells.
    It is not putting the key words back into the cell contents.

    Please Login or Register  to view this content.
    ANY ideas or help would be appreciated.
    Hope everyone has a great weekend (tomorrow is FRIDAY!!!).

    cliff
    Last edited by GS7clw; 02-24-2011 at 01:16 PM.

  2. #2
    Forum Guru
    Join Date
    08-05-2004
    Location
    NJ
    MS-Off Ver
    365
    Posts
    13,582

    Re: rewriting a cell's contents within a range of cells

    When you go to your cases, i.e. Case 2, you only set up the string as Firstword & Secondword whereas, your actual value might have only 3rd and 4th word. A better way to do it is to concatenate as you go along. Try this
    Please Login or Register  to view this content.
    Does that work for you?
    ChemistB
    My 2?

    substitute commas with semi-colons if your region settings requires
    Don't forget to mark threads as "Solved" (Edit First post>Advanced>Change Prefix)
    If I helped, Don't forget to add to my reputation (click on the little star at bottom of this post)

    Forum Rules: How to use code tags, mark a thread solved, and keep yourself out of trouble

  3. #3
    Registered User
    Join Date
    02-24-2011
    Location
    Somewhere, Ohio
    MS-Off Ver
    Excel 2007
    Posts
    20

    Re: rewriting a cell's contents within a range of cells

    Fantastic and the way you have done it I can add and subtract words as needed.

    Excel locked up after running this macro but I just changed L:L to L1:200 to stop it running.
    (Will never have even close to 200 so it works great AND the way you did it I can add words as needed.

    THANK YOU!!!!

    Have a great weekend
    cliff
    Last edited by GS7clw; 02-24-2011 at 01:18 PM.

+ 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