+ Reply to Thread
Results 1 to 10 of 10

I need code to search for certain text, then delete the row, plus others. $30 REWARD

  1. #1
    Registered User
    Join Date
    07-08-2009
    Location
    PA, USA
    MS-Off Ver
    Excel 2003
    Posts
    6

    Question I need code to search for certain text, then delete the row, plus others. $30 REWARD

    Here is what Im trying to do: I have a VERY large excel file (15,000+ lines) that has groups of text (this is all in one column)

    I want excel to search for the cells with "UID" and delete that row plus every non-blank row above it. (so it deletes the entire "group") Here is example layout of what Im working with. The end result should be only "groups" without the text "UID" following it.

    ExampleCell1
    ExampleCell2
    ExampleCell3
    UID = example

    ExampleCell1
    ExampleCell2
    ExampleCell3

    ExampleCell1
    ExampleCell2
    ExampleCell3
    UID = example

    Now Im thinking this may be impossible, but I've seen some crazy things done with excel macros and was really hoping someone can help me out. Otherwise Im doing this manually for 15,000 lines of text.

    Any suggestions are GREATLY appreciated!!!!!!!


    I will gladly transfer $30 to the first person to solve this and has a PayPal account!
    Last edited by mainer188; 07-09-2009 at 02:52 PM.

  2. #2
    Forum Contributor
    Join Date
    02-23-2006
    Location
    Near London, England
    MS-Off Ver
    Office 2003
    Posts
    770

    Re: I need code to search for certain text, then delete the row, plus others. $30 REW

    Are you able to upload a zipped version of the file?
    Also are you wanting to keep a blank line between each group, or should they be removed as well?

    Thanks

    EDIT Also what is the EXACT format of the text in the UID cells? Is it "UID = " followed by some more text? (ie. are those spaces there? is the equality sign there?)
    If you find the response helpful please click the scales in the blue bar above and rate it
    If you don't like the response, don't bother with the scales, they are not for you

  3. #3
    Forum Expert royUK's Avatar
    Join Date
    11-18-2003
    Location
    Derbyshire,UK
    MS-Off Ver
    Xp; 2007; 2010
    Posts
    26,200

    Re: I need code to search for certain text, then delete the row, plus others. $30 REW

    To best describe or illustrate your problem you would be better off attaching a dummy workbook, the workbook should contain the same structure and some dummy data of the same type as the type you have in your real workbook - so, if a cell contains numbers & letters in this format abc-123 then that should be reflected in the dummy workbook.

    If needed supply a before and after sheet in the workbook so the person helping you can see what you are trying to achieve.

    Doing this will ensure you get the result you need!

    This should really be in the Commercial Exchange Forum
    Hope that helps.

    RoyUK
    --------
    For Excel Tips & Solutions, free examples and tutorials why not check out my web site

    Free DataBaseForm example

  4. #4
    Registered User
    Join Date
    07-08-2009
    Location
    PA, USA
    MS-Off Ver
    Excel 2003
    Posts
    6

    Re: I need code to search for certain text, then delete the row, plus others. $30 REW

    Unfortunately, I can not upload the actual file, It contains private company data.

    And yes, the cell with the "UID" text will look exactly like [ UID: "some other text" ]
    Its a colon, not an equal sign, I apologize.
    UID: will always be at the beginning if thats what your hoping.

    A blank line should be left between each group.
    Last edited by mainer188; 07-09-2009 at 11:57 AM.

  5. #5
    Registered User
    Join Date
    07-08-2009
    Location
    PA, USA
    MS-Off Ver
    Excel 2003
    Posts
    6

    Re: I need code to search for certain text, then delete the row, plus others. $30 REW

    I have attached an example workbook. It includes two sheets, a before and a desired after.
    Attached Files Attached Files

  6. #6
    Forum Expert royUK's Avatar
    Join Date
    11-18-2003
    Location
    Derbyshire,UK
    MS-Off Ver
    Xp; 2007; 2010
    Posts
    26,200

    Re: I need code to search for certain text, then delete the row, plus others. $30 REW

    This should do it
    Please Login or Register  to view this content.

  7. #7
    Forum Contributor
    Join Date
    02-23-2006
    Location
    Near London, England
    MS-Off Ver
    Office 2003
    Posts
    770

    Re: I need code to search for certain text, then delete the row, plus others. $30 REW

    This should do it:

    Please Login or Register  to view this content.

  8. #8
    Forum Expert Paul's Avatar
    Join Date
    02-05-2007
    Location
    Wisconsin
    MS-Off Ver
    2016/365
    Posts
    6,885

    Re: I need code to search for certain text, then delete the row, plus others. $30 REW

    A bit shorter option:
    Please Login or Register  to view this content.
    Last edited by Paul; 07-09-2009 at 01:03 PM. Reason: Added Application.Screenupdating lines

  9. #9
    Registered User
    Join Date
    07-08-2009
    Location
    PA, USA
    MS-Off Ver
    Excel 2003
    Posts
    6

    Thumbs up Re: I need code to search for certain text, then delete the row, plus others. $30 REW

    SOLVED! Thanks to RoyUK's code.

    Phil_V, I couldnt get your code to run. I kept getting a "Run-Time Error 424" "Object Required" error.

    RoyUK, my personal email is "[email protected]", email me your paypal account name and Ill send your $30.

    Thanks to all who replied!!
    Last edited by mainer188; 07-09-2009 at 02:54 PM.

  10. #10
    Forum Contributor
    Join Date
    02-23-2006
    Location
    Near London, England
    MS-Off Ver
    Office 2003
    Posts
    770

    Re: I need code to search for certain text, then delete the row, plus others. $30 REW

    Quote Originally Posted by mainer188 View Post
    Phil_V, I couldnt get your code to run. I kept getting a "Run-Time Error 424" "Object Required" error.
    No idea why you would be getting that, it runs fine here everytime with the sample data you provided.
    Anyhow for completeness here is my more condensed version:

    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