+ Reply to Thread
Results 1 to 4 of 4

Deleting Entire Row - When cell in column contains a key word

  1. #1
    Registered User
    Join Date
    07-25-2013
    Location
    United States
    MS-Off Ver
    Excel 2007
    Posts
    88

    Deleting Entire Row - When cell in column contains a key word

    Hello,

    Is there a simple way to create a macro that will DELETE and entire row and move up the cells beneath it if a cell in a certain column meets a specified condition?

    For example, I have a worksheet that contains a list of names in column D, and information about those people in columns A,-C and E-H. I want to remove all rows in which a person has the name "John", "Mary", or "Robert", regardless of where the name is located in the cell. So "John Smith", "Albert Robert Jones", and "Mary Smith" would all be examples of names I would want removed. How can I put together a macro to delete and shift up rows containing these names?

    Thank you in advance for reading. I am new to this forum, but I'll make sure to "add to reputation" for those who help.

    -Student1990

  2. #2
    Forum Guru xladept's Avatar
    Join Date
    04-14-2012
    Location
    Pasadena, California
    MS-Off Ver
    Excel 2003,2010
    Posts
    12,378

    Re: Deleting Entire Row - When cell in column contains a key word

    Hi Stu,

    Here's a quickie:

    Please Login or Register  to view this content.
    Directions for running the routine(s) just supplied

    Copy the code to the clipboard

    Open your Workbook

    Save your Workbook or Another Workbook designated for Macros as Macro_Enabled

    Press ALT + F11 to open the Visual Basic Editor.

    Select “Module” from the Insert menu

    Type "Option Explicit" then paste the code under it

    With the cursor between Sub and End Sub press F5 (F8 to Single Step)

    OR

    Press ALT + Q to close the code window.

    Press ALT + F8 then double click on the macro name
    If I've helped you, please consider adding to my reputation - just click on the liitle star at the left.

    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~(Pride has no aftertaste.)

    You can't do one thing. XLAdept

    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~aka Orrin

  3. #3
    Registered User
    Join Date
    07-25-2013
    Location
    United States
    MS-Off Ver
    Excel 2007
    Posts
    88

    Re: Deleting Entire Row - When cell in column contains a key word

    xladept: This is exactly what I was looking for. Thank you for taking the time to put this together. My goal is to learn to be able to do this on my own, so I'm going to play around with your example for a different data set. Thanks again!

    -Student1990

  4. #4
    Forum Guru xladept's Avatar
    Join Date
    04-14-2012
    Location
    Pasadena, California
    MS-Off Ver
    Excel 2003,2010
    Posts
    12,378

    Re: Deleting Entire Row - When cell in column contains a key word

    You're welcome!

+ 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. comparing the column headers, then deleting the entire column iif duplicates occur
    By vindieselgal in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 07-25-2011, 04:53 AM
  2. How to search for a word in a column and have entire row opaque once word is found
    By copleyr in forum Excel Programming / VBA / Macros
    Replies: 17
    Last Post: 09-04-2009, 07:11 PM
  3. Deleting entire row if value in column A = 0
    By pyufak in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 02-07-2009, 05:43 PM
  4. [SOLVED] deleting entire rows with the same cell value in the first column
    By Pedro F. in forum Excel General
    Replies: 3
    Last Post: 01-11-2006, 03:15 PM
  5. Deleting the hyperlinks form an entire column...??
    By chai in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 04-04-2005, 03:37 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