+ Reply to Thread
Results 1 to 6 of 6

Delete rows that match criteria

  1. #1
    Registered User
    Join Date
    11-06-2008
    Location
    Boston
    MS-Off Ver
    2003 SP3
    Posts
    42

    Delete rows that match criteria

    I would like a macro that scrolls through each row and deletes it if it contains the word "Account" in column B.

    Thanks for any help
    Last edited by PhilSM; 02-02-2009 at 11:07 AM.

  2. #2
    Forum Guru DonkeyOte's Avatar
    Join Date
    10-22-2008
    Location
    Northumberland, UK
    MS-Off Ver
    O365
    Posts
    21,531

    Re: Delete rows that match criteria

    There a variety of ways to do this ... some will loop but I quite like to use the following method:

    Please Login or Register  to view this content.

  3. #3
    Registered User
    Join Date
    11-06-2008
    Location
    Boston
    MS-Off Ver
    2003 SP3
    Posts
    42

    Re: Delete rows that match criteria

    Quite like this, is it possible to make the search and column variable ?

  4. #4
    Forum Guru DonkeyOte's Avatar
    Join Date
    10-22-2008
    Location
    Northumberland, UK
    MS-Off Ver
    O365
    Posts
    21,531

    Re: Delete rows that match criteria

    To be honest if you wanted it to be dynamic etc you would be best served reverting to the traditional loop & find method ... such that you can easily do partial matches etc...

    A slightly more dynamic version of the prior method would be along the lines of:

    Please Login or Register  to view this content.
    But to reiterate - making the above more flexible is pretty worthless given standard Find method offers greater inherent flexibility for less effort ;-)

    As I say for the odd check here & there I prefer the .SpecialCells method as I'm not a fan of looping... anything more complex... Find & Loop... you should find lots of examples here of the Find & Delete approach.
    Last edited by DonkeyOte; 02-02-2009 at 08:55 AM. Reason: typo's...

  5. #5
    Valued Forum Contributor Shijesh Kumar's Avatar
    Join Date
    05-26-2008
    Location
    Bangalore / India
    MS-Off Ver
    2000
    Posts
    717

    Re: Delete rows that match criteria

    try this if this is of any help


    Below code will ask you what you want to delete and in which column u want to search

    Eg. Input what u want to delete as "Account"
    and for Column enter 1 , 2 , 3 etc.

    Please Login or Register  to view this content.

  6. #6
    Registered User
    Join Date
    11-06-2008
    Location
    Boston
    MS-Off Ver
    2003 SP3
    Posts
    42

    Re: Delete rows that match criteria

    Thanks very much, these both work a treat.

+ 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