+ Reply to Thread
Results 1 to 8 of 8

Remove all rows after Value is found in column

  1. #1
    Forum Contributor
    Join Date
    09-07-2010
    Location
    London
    MS-Off Ver
    Excel 2010
    Posts
    358

    Remove all rows after Value is found in column

    Hey,

    The macro I'm looking for should be fairly simple but everything I've tried isn't working and I don't know what I'm doing wrong. I need a macro to look at the name in: C2 and search from C3 down to end of page, the we only need to know when it first encounters the name. (C7 in my example) and then it needs to delete that row and other rows below .

    So in this example it looks at C2 and finds James Low it searchs and finds James Low on C7 and then deletes the rows from 7 to 21 (A7:D21) (See attachment)

    Thanks in advance
    - Hyflex
    Attached Files Attached Files

  2. #2
    Forum Guru
    Join Date
    08-26-2007
    Location
    London
    Posts
    4,606

    Re: Remove all rows after Value is found in column

    Try this:
    Please Login or Register  to view this content.

  3. #3
    Forum Guru MarvinP's Avatar
    Join Date
    07-23-2010
    Location
    Woodinville, WA
    MS-Off Ver
    Office 365
    Posts
    16,169

    Re: Remove all rows after Value is found in column

    Hi Hyflex,
    see if the following code does what you want.
    Please Login or Register  to view this content.
    Attached Files Attached Files
    One test is worth a thousand opinions.
    Click the * Add Reputation below to say thanks.

  4. #4
    Forum Contributor
    Join Date
    09-07-2010
    Location
    London
    MS-Off Ver
    Excel 2010
    Posts
    358

    Re: Remove all rows after Value is found in column

    Awesome, works perfectly.

    Could I possibly ask for a similar macro but instead of looking at C2 it needs to look at B2 and when it needs to go down each cell until B finds a different value when it finds a different value to what is in B2 it deletes that row and all rows below it.

  5. #5
    Forum Guru
    Join Date
    08-26-2007
    Location
    London
    Posts
    4,606

    Re: Remove all rows after Value is found in column

    So in your example that would leave only row 2?

  6. #6
    Forum Contributor
    Join Date
    09-07-2010
    Location
    London
    MS-Off Ver
    Excel 2010
    Posts
    358

    Re: Remove all rows after Value is found in column

    Quote Originally Posted by StephenR View Post
    So in your example that would leave only row 2?
    Yeah, the examples quite poor for the secondary macro.

  7. #7
    Forum Guru
    Join Date
    08-26-2007
    Location
    London
    Posts
    4,606

    Re: Remove all rows after Value is found in column

    With apologies to MarvinP...
    Please Login or Register  to view this content.

  8. #8
    Forum Guru MarvinP's Avatar
    Join Date
    07-23-2010
    Location
    Woodinville, WA
    MS-Off Ver
    Office 365
    Posts
    16,169

    Re: Remove all rows after Value is found in column

    Imitation = flattery - OK with me, no apologies needed.

+ 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