+ Reply to Thread
Results 1 to 4 of 4

Developing a macro to locate a keyword, delete that row and all rows below

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

    Developing a macro to locate a keyword, delete that row and all rows below

    Hello,

    I know I've seen similar posts on here for a problem like mine, but I've been unable to figure out a solution from previous commentary. I want to create a simple macro to locate a specific row, delete that row, and then delete all rows below it.

    For example, in the attached file row 30 contains headers for deactivated accounts. The information for these accounts is directly below. Rows 1 through 29 contain information for active accounts. However, the number of active accounts could change daily - meaning I can't just delete downwards from row 30 each day. The deactivated accounts contain a column heading (column B) which reads "GSP Acct No". If a macro could find which cell that "GSP Acct No" is in, delete that row and all rows below, then I would be left with only relevant information on my worksheet.

    Again, I apologize for the simplicity of my request. I am a beginner and looking to learn more, so I appreciate any insight that anyone can share.

    Thank you.

    DeleteRowsExample_MACRO.xlsx

  2. #2
    Forum Guru
    Join Date
    07-25-2011
    Location
    Florida
    MS-Off Ver
    Excel 2003
    Posts
    9,643

    Re: Developing a macro to locate a keyword, delete that row and all rows below

    Try this...

    Please Login or Register  to view this content.
    Surround your VBA code with CODE tags e.g.;
    [CODE]your VBA code here[/CODE]
    The # button in the forum editor will apply CODE tags around your selected text.

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

    Re: Developing a macro to locate a keyword, delete that row and all rows below

    AlphaFrog: Thank you very much, this exactly what I'm looking for. I can learn from this example, as I'm sure I'll come across a similar situation again.

    Another question: I want to use this macro in a workbook that contains multiple worksheets and several other macros. When I create a new module and enter the code for this routine, how can I make sure Excel is only applying the routine to the worksheet entitled "Sheet3"? Would I enter something like:

    Worksheets ("Sheet3").Activate

    At the beginning of the routine?

    Thank you again for your prompt and helpful response.

  4. #4
    Forum Guru
    Join Date
    07-25-2011
    Location
    Florida
    MS-Off Ver
    Excel 2003
    Posts
    9,643

    Re: Developing a macro to locate a keyword, delete that row and all rows below

    Quote Originally Posted by Student1990 View Post
    ... how can I make sure Excel is only applying the routine to the worksheet entitled "Sheet3"? Would I enter something like:

    Worksheets ("Sheet3").Activate

    At the beginning of the routine?

    Thank you again for your prompt and helpful response.

    That could work and 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. Replies: 6
    Last Post: 03-18-2014, 11:16 AM
  2. [SOLVED] Find keyword and delete the rows below and above
    By zeroist in forum Excel Programming / VBA / Macros
    Replies: 25
    Last Post: 09-13-2013, 03:45 AM
  3. [SOLVED] Macro to Locate and Delete File saved from cell variable
    By ut1anderson in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 05-02-2013, 04:22 PM
  4. [SOLVED] Locate column with specific title and delete rows if predefined set of text is found
    By johnny_tc in forum Excel Programming / VBA / Macros
    Replies: 8
    Last Post: 10-25-2012, 01:57 PM
  5. VBA Popup to search a sheet and delete rows based on keyword entered
    By MichaelJG in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 06-05-2011, 08:08 AM

Tags for this Thread

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