+ Reply to Thread
Results 1 to 5 of 5

if a cell contains text then delete the row

  1. #1
    Registered User
    Join Date
    09-03-2013
    Location
    Nottingham, England
    MS-Off Ver
    Excel 2007
    Posts
    2

    if a cell contains text then delete the row

    Hi
    I am trying to delete rows if a column contains text.
    Basically if column O contains text (this could be anything) then delete the whole row. This should then just leave the rows that have a blank cell in column O

    Thanks in advance

  2. #2
    Administrator 6StringJazzer's Avatar
    Join Date
    01-27-2010
    Location
    Tysons Corner, VA, USA
    MS-Off Ver
    MS365 Family 64-bit
    Posts
    24,721

    Re: if a cell contains text then delete the row

    Welcome to the Forum debsch!

    Try this. However, note that this deletes the row if column O contains anything. You specifically said if it contains text, but I assumed you meant text, dates, or numbers.

    Please Login or Register  to view this content.
    Last edited by 6StringJazzer; 09-03-2013 at 10:21 AM. Reason: removed Debug.Print line from code
    Jeff
    | | |會 |會 |會 |會 | |:| | |會 |會
    Read the rules
    Use code tags to [code]enclose your code![/code]

  3. #3
    Registered User
    Join Date
    09-03-2013
    Location
    Nottingham, England
    MS-Off Ver
    Excel 2007
    Posts
    2

    Re: if a cell contains text then delete the row

    Hi

    I have tried this but it bring sback the error 'Runtime error 424 Object Required'. When I hover over the code it tells me that r is nothing.

    what am I missing?!

  4. #4
    Forum Expert
    Join Date
    03-28-2012
    Location
    TBA
    MS-Off Ver
    Office 365
    Posts
    12,454

    Re: if a cell contains text then delete the row

    I do not know what do you mean by texting with out seeing your data, but if you want to delete non black cells

    Please Login or Register  to view this content.

  5. #5
    Administrator 6StringJazzer's Avatar
    Join Date
    01-27-2010
    Location
    Tysons Corner, VA, USA
    MS-Off Ver
    MS365 Family 64-bit
    Posts
    24,721

    Re: if a cell contains text then delete the row

    I think AB33 has good alternate code. The problem you are having with my code is that it must be placed in the code module for the sheet you want to work on; I am guessing you put it in a Module. AB33's code will work in a Module and will work (I have not tested it) on whatever the ActiveSheet happens to be.

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. [SOLVED] If Or statement to check cell text and delete entire row if text is found
    By VBA FTW in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 08-08-2013, 11:46 AM
  2. If text in cell contains text found in another cell, delete row.
    By BPSJACK in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 11-28-2012, 09:42 AM
  3. Delete row if cell J contains any text
    By tactical in forum Excel Programming / VBA / Macros
    Replies: 11
    Last Post: 06-01-2012, 12:45 PM
  4. Find and delete text from a cell with lots of text.
    By leonardzen in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 06-22-2011, 10:52 AM
  5. Delete cell with red text
    By Kara in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 07-26-2005, 02:05 PM

Tags for this Thread

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