+ Reply to Thread
Results 1 to 10 of 10

Macro help to search in all columns and delete rows accordingly

  1. #1
    Registered User
    Join Date
    06-24-2011
    Location
    Philadelphia, USA
    MS-Off Ver
    Excel 2010
    Posts
    15

    Question Macro help to search in all columns and delete rows accordingly

    Hello everyone!

    I have a spreadsheet with many, many columns.
    I would like to create a macro that can search for a specific word throughout the entire spreadsheet (for example, the word "Yes" in any column), and delete every row/entry that has the specific word in it, no matter what column.

    Right now, I only have a macro that seems to search one column at a time. The code is:

    Please Login or Register  to view this content.
    Can I have a macro automatically search every column without me having to define the limits?

    Thanks,
    Jonny
    Last edited by JonnyNYC90; 12-19-2012 at 01:26 PM. Reason: Fixed code.

  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: Macro help to search in all columns and delete rows accordingly

    Maybe:

    Please Login or Register  to view this content.

  3. #3
    Registered User
    Join Date
    06-24-2011
    Location
    Philadelphia, USA
    MS-Off Ver
    Excel 2010
    Posts
    15

    Re: Macro help to search in all columns and delete rows accordingly

    Hi John,

    Thank you so much for your help. While it does delete rows with the proper condition ("Yes" in any column), it does not delete every row. It seems to delete every other row, and I'm stumped as to why.

    Thanks,
    Jonny

  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: Macro help to search in all columns and delete rows accordingly

    In your data do you have cells which may have spaces dividing words (i.e "110 22", "good day", ect.)?

  5. #5
    Forum Expert Pepe Le Mokko's Avatar
    Join Date
    05-14-2009
    Location
    Belgium
    MS-Off Ver
    O365 v 2402
    Posts
    13,462

    Re: Macro help to search in all columns and delete rows accordingly

    Your post does not comply with Rule 3 of our Forum RULES. Use code tags around code. Posting code without them makes your code hard to read and difficult to be copied for testing. Highlight your code and click the # at the top of your post window. For more information about these and other tags, found here

  6. #6
    Forum Expert Pepe Le Mokko's Avatar
    Join Date
    05-14-2009
    Location
    Belgium
    MS-Off Ver
    O365 v 2402
    Posts
    13,462

    Re: Macro help to search in all columns and delete rows accordingly

    Are you using 2003 as indicated?

  7. #7
    Registered User
    Join Date
    06-24-2011
    Location
    Philadelphia, USA
    MS-Off Ver
    Excel 2010
    Posts
    15

    Re: Macro help to search in all columns and delete rows accordingly

    Thank you very much Pepe Le Mokko...my apologies for being ignorant about the code tags and not updating my version of Excel.
    I am using Microsoft Excel 2010.

  8. #8
    Forum Expert Pepe Le Mokko's Avatar
    Join Date
    05-14-2009
    Location
    Belgium
    MS-Off Ver
    O365 v 2402
    Posts
    13,462

    Re: Macro help to search in all columns and delete rows accordingly

    You will find what looks like an easy solution at this place. Perhaps recording a macro using this technique can get you on track?

  9. #9
    Registered User
    Join Date
    06-24-2011
    Location
    Philadelphia, USA
    MS-Off Ver
    Excel 2010
    Posts
    15

    Re: Macro help to search in all columns and delete rows accordingly

    Thank you very much Pepe.

    I have tried that solution, but need something that can search multiple words in multiple columns at once.
    Also, recording a macro using that technique seems to not work whatsoever. It's a bit frustrating. It only seems to record the deletion of rows, with no rhyme or reason.

    I will keep searching...any further help would be MUCH appreciated.

    Thanks,
    Jonny

  10. #10
    Registered User
    Join Date
    06-24-2011
    Location
    Philadelphia, USA
    MS-Off Ver
    Excel 2010
    Posts
    15

    Re: Macro help to search in all columns and delete rows accordingly

    Here is what I have now!
    The macro works, but can only seem to search one word at a time. Does anyone know how to change this?

    Please Login or Register  to view this content.

+ 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