+ Reply to Thread
Results 1 to 8 of 8

Find a value and delete the next 8 rows

  1. #1
    Registered User
    Join Date
    09-07-2012
    Location
    Wales, UK
    MS-Off Ver
    2013
    Posts
    4

    Find a value and delete the next 8 rows

    I have a table that has been extracted from a large pdf document. They are actually delivery notes and I am trying to nail down a stock discrepancy.

    I want to find a value in a cell, then delete the next 8 rows. I have done quite a bit with VBA in Access, but never in Excel and I'm not sure where to start.

    I have attached 2 spreadsheets, Before.xlsx and After.xlsx I want to find 'PROD1' in Before.xlsx then get rid of the next 8 rows to give the result in After.xlsx

    Can anyone point me in the right direction? I will want to do a more complicated procedure later, but if I use this as a starting point I should be able to figure out the rest myself.
    Attached Files Attached Files
    Last edited by PeteW1959; 04-01-2015 at 11:33 AM. Reason: Forgot to attach files

  2. #2
    Forum Expert
    Join Date
    06-12-2012
    Location
    Ridgefield Park, New Jersey
    MS-Off Ver
    Excel 2003,2007,2010
    Posts
    10,241

    Re: Find a value and delete the next 8 rows

    I don't see any attachments?

  3. #3
    Registered User
    Join Date
    09-07-2012
    Location
    Wales, UK
    MS-Off Ver
    2013
    Posts
    4

    Re: Find a value and delete the next 8 rows

    Ooops, my bad. Files now attached.

  4. #4
    Forum Expert
    Join Date
    06-12-2012
    Location
    Ridgefield Park, New Jersey
    MS-Off Ver
    Excel 2003,2007,2010
    Posts
    10,241

    Re: Find a value and delete the next 8 rows

    Maybe:

    Please Login or Register  to view this content.

  5. #5
    Registered User
    Join Date
    09-07-2012
    Location
    Wales, UK
    MS-Off Ver
    2013
    Posts
    4

    Re: Find a value and delete the next 8 rows

    Thanks, John, that does the trick. I am trying to understand how this code works so could you please explain a couple of things.

    Why use "B" in the range command?

    What does the 3 in the End command do?

  6. #6
    Forum Expert
    Join Date
    06-12-2012
    Location
    Ridgefield Park, New Jersey
    MS-Off Ver
    Excel 2003,2007,2010
    Posts
    10,241

    Re: Find a value and delete the next 8 rows

    I used Column B to find the last row because there were no gaps. I could have used activesheet.usedrange.rows.count, which would have found the last cell in the range with data.

    .End(3).Row - same as .End(xlUp).Row. A shorter version to write xlUp in this instance.

  7. #7
    Registered User
    Join Date
    09-07-2012
    Location
    Wales, UK
    MS-Off Ver
    2013
    Posts
    4

    Re: Find a value and delete the next 8 rows

    Ah, I see. Thanks for your help John.

  8. #8
    Forum Expert
    Join Date
    06-12-2012
    Location
    Ridgefield Park, New Jersey
    MS-Off Ver
    Excel 2003,2007,2010
    Posts
    10,241

    Re: Find a value and delete the next 8 rows

    You're welcome. Glad to help out and thanks for the feedback. Please mark this thread as SOLVED. Refer to link for guidance.

    http://www.excelforum.com/forum-rule...rum-rules.html

+ 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. Macro To Find Rows With Duplicates, Compare Cells, And Delete Rows. - Excel
    By Kwame001 in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 09-26-2013, 10:41 AM
  2. Find and Delete Rows Above/in between
    By bruizer31 in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 05-20-2013, 04:30 PM
  3. Replies: 4
    Last Post: 09-18-2012, 10:54 AM
  4. Replies: 13
    Last Post: 08-23-2011, 11:00 AM
  5. Find & Delete Rows
    By Steve Wallis in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 06-17-2005, 03:05 AM

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