+ Reply to Thread
Results 1 to 5 of 5

Macro to delete specific rows

  1. #1
    Registered User
    Join Date
    02-02-2013
    Location
    MA
    MS-Off Ver
    365
    Posts
    43

    Macro to delete specific rows

    Having a hard time with this...

    I need to search thru 'X' amount of rows, delete the row if it contains the text 'LVL', and the six rows before it, and the one after it. So if LVL is in A55, rows 49 thru 56 will be deleted. The 'LVL' text will only show up in column A. The group of rows I want to delete repeats itself thru the sheet.

    Thanks.

  2. #2
    Forum Expert
    Join Date
    11-28-2012
    Location
    Guatemala
    MS-Off Ver
    Excel 2010
    Posts
    2,394

    Re: Macro to delete specific rows

    Try this code in a macro
    Please Login or Register  to view this content.

  3. #3
    Forum Expert
    Join Date
    07-31-2010
    Location
    California
    MS-Off Ver
    Excel 2007
    Posts
    4,070

    Re: Macro to delete specific rows

    What determines "X"? I assumed the last used row. I also assumed that you don't have any cells in column A highlighted as red. I wanted to try a thought that I had so I highlighted the rows to be deleted first then come back and delete them. Using the Find/Next method would probably work better here, I just wanted to use Instr since it has been a while. Let me know how it works.

    Please Login or Register  to view this content.

  4. #4
    Registered User
    Join Date
    02-02-2013
    Location
    MA
    MS-Off Ver
    365
    Posts
    43

    Re: Macro to delete specific rows

    It never goes into the while portion of the code. It skips to the end.

  5. #5
    Registered User
    Join Date
    02-02-2013
    Location
    MA
    MS-Off Ver
    365
    Posts
    43

    Re: Macro to delete specific rows

    Changed a couple things with your advice... this seems to be working.

    Please Login or Register  to view this content.
    I see your point. My apologizes I didn't make that clear about 'X'.

+ 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