+ Reply to Thread
Results 1 to 7 of 7

Find Criteria, Delete rows above and below

  1. #1
    Forum Contributor
    Join Date
    11-14-2007
    Posts
    111

    Find Criteria, Delete rows above and below

    I need to search column A for "Brown..." then delete three rows above an four rows below that and loop it until the end of the sheet. Sheet contains 6000 rows. Nothing manual is fast because of gaps between the "Brown..." and i have not bee able to get any VBA Coding to work correctly. I am starting over an looking for some HELP

  2. #2
    Forum Contributor SOS's Avatar
    Join Date
    01-26-2004
    Location
    Glasgow, Scotland
    MS-Off Ver
    Excel 2003
    Posts
    327
    Hi Ada01

    I put together this code - crude I know but it seems to work

    Please Login or Register  to view this content.
    Hope this helps

    Seamus

  3. #3
    Forum Contributor
    Join Date
    11-14-2007
    Posts
    111

    RE: Not Deleting??

    The macro won't work, it come close, it seems to be finding, just not deleting...i haven't had any luck with minor adjustments.
    Attached Files Attached Files

  4. #4
    Forum Contributor SOS's Avatar
    Join Date
    01-26-2004
    Location
    Glasgow, Scotland
    MS-Off Ver
    Excel 2003
    Posts
    327
    Ada01,

    I looked at your example. Did not realise that there would be many blank cells between each "Brown".

    What do you want to do exactly? Delete the third row above and fourth row below Brown OR delete all three rows above and four rows below Brown?

    The code I posted finds the first instance of "Brown" and then deletes the row three above that row and four rows below that.

    Not sure what you mean by "not coming close"

    Regards

  5. #5
    Forum Contributor SOS's Avatar
    Join Date
    01-26-2004
    Location
    Glasgow, Scotland
    MS-Off Ver
    Excel 2003
    Posts
    327
    Ada01,

    I've looked again and the code below does the following:

    Starts at A1 and looks for "Brown Printing Company" and when it finds it, selects from 3 rows above to 4 rows below and deletes them. It carries on until it returns to A1 again at which point the Sub ends.

    Is that more what you were after?


    Please Login or Register  to view this content.
    Regards

  6. #6
    Forum Contributor
    Join Date
    11-14-2007
    Posts
    111

    Works

    I am sorry, i was not able to get back on unitl this morning. the macro worked great, it took me over an 3 hours to do this manually last time to 7 reports, each over 6000 rows.

    Thanks a lot!!

  7. #7
    Forum Contributor SOS's Avatar
    Join Date
    01-26-2004
    Location
    Glasgow, Scotland
    MS-Off Ver
    Excel 2003
    Posts
    327
    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)

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