+ Reply to Thread
Results 1 to 12 of 12

Delete row if cell J contains any text

  1. #1
    Registered User
    Join Date
    05-31-2011
    Location
    US
    MS-Off Ver
    Excel 2007
    Posts
    37

    Delete row if cell J contains any text

    Hello,

    I am trying to write a program to delete a row if column J contains any sort of text. The text in column J is not the same. Any help is appreciated!

    TIA
    Last edited by tactical; 05-30-2012 at 03:24 PM.

  2. #2
    Valued Forum Contributor AlvaroSiza's Avatar
    Join Date
    09-19-2007
    Location
    Staffordshire
    MS-Off Ver
    2007
    Posts
    591

    Re: Delete row if cell J contains any text

    *Untested*

    Please make a copy of your workbook and test on the copy. If you are unfamiliar with how to run the code, please use the instructions in my signature.

    Please Login or Register  to view this content.
    Perhaps it was the Noid who should have avoided me...
    If you are satisfied with my solution click the small star icon on the left. Thanks
    1. Make a copy of your workbook and run the following code on your copy (just in case)
    2. With excel open, press ALT+F11 to open the Visual Basic Editor (VBE). From the "Insert" menu, select "Module".
    3. Paste the code from above into the empty white space. Close the VBE.
    4. From the developer tab, choose "Macros", select the Sub Name, and click "Run".

  3. #3
    Forum Expert
    Join Date
    05-30-2012
    Location
    The Netherlands
    MS-Off Ver
    Office 365
    Posts
    14,987

    Re: Delete row if cell J contains any text

    I have used this one.

    Please Login or Register  to view this content.
    Columns(11) = "J"
    Last edited by oeldere; 05-30-2012 at 04:44 PM. Reason: changed text used

  4. #4
    Registered User
    Join Date
    05-31-2011
    Location
    US
    MS-Off Ver
    Excel 2007
    Posts
    37

    Re: Delete row if cell J contains any text

    Quote Originally Posted by AlvaroSiza View Post
    *Untested*

    Please make a copy of your workbook and test on the copy. If you are unfamiliar with how to run the code, please use the instructions in my signature.

    Please Login or Register  to view this content.
    Im getting a on Method 'Range' of object '_Global' failed error with this code.

    I don't think it like the "If Application.WorksheetFunction.IsText(Range(rngCell)) Then" line
    Last edited by tactical; 05-30-2012 at 04:54 PM.

  5. #5
    Registered User
    Join Date
    05-31-2011
    Location
    US
    MS-Off Ver
    Excel 2007
    Posts
    37

    Re: Delete row if cell J contains any text

    Quote Originally Posted by oeldere View Post
    I have used this one.

    Please Login or Register  to view this content.
    Columns(11) = "J"
    J is actually column 10. I am getting Delete method of Range class failed error for this one

  6. #6
    Forum Expert
    Join Date
    05-30-2012
    Location
    The Netherlands
    MS-Off Ver
    Office 365
    Posts
    14,987

    Re: Delete row if cell J contains any text

    Please Login or Register  to view this content.
    you are right => J= colomn 10

    I send you my example.

    first run macro

    Sub delete_NOT_empty_row_in_columnC_oeldere()

    then run

    Sub delete_empty_row_in_columnA()

    This one works fine for me.
    Attached Files Attached Files

  7. #7
    Registered User
    Join Date
    05-31-2011
    Location
    US
    MS-Off Ver
    Excel 2007
    Posts
    37

    Re: Delete row if cell J contains any text

    Quote Originally Posted by oeldere View Post
    Please Login or Register  to view this content.
    you are right => J= colomn 10

    I send you my example.

    first run macro

    Sub delete_NOT_empty_row_in_columnC_oeldere()

    then run

    Sub delete_empty_row_in_columnA()

    This one works fine for me.
    Yours is working, but mine is not.

  8. #8
    Forum Expert
    Join Date
    05-30-2012
    Location
    The Netherlands
    MS-Off Ver
    Office 365
    Posts
    14,987

    Re: Delete row if cell J contains any text

    Maybe you can post your example, without personal information.

    Then i can try your code on my PC.
    Last edited by oeldere; 05-30-2012 at 05:45 PM. Reason: changed text

  9. #9
    Registered User
    Join Date
    05-31-2011
    Location
    US
    MS-Off Ver
    Excel 2007
    Posts
    37

    Re: Delete row if cell J contains any text

    Here is my workbook.

    Also, the number of rows always changes, therefore it would also have to work for more data entries.
    Again, if a cell in column J is empty, I want to delete the row that corresponds to empty cells.
    I appreciate your help!
    Attached Files Attached Files

  10. #10
    Valued Forum Contributor
    Join Date
    02-12-2011
    Location
    The Netherlands
    MS-Off Ver
    365
    Posts
    864

    Re: Delete row if cell J contains any text

    Please Login or Register  to view this content.
    Harry.

  11. #11
    Registered User
    Join Date
    05-31-2011
    Location
    US
    MS-Off Ver
    Excel 2007
    Posts
    37

    Re: Delete row if cell J contains any text

    Quote Originally Posted by HSV View Post
    Please Login or Register  to view this content.
    This deletes the empty rows. What do I need instead of "" to make it delete rows that contain any string?

  12. #12
    Valued Forum Contributor
    Join Date
    02-12-2011
    Location
    The Netherlands
    MS-Off Ver
    365
    Posts
    864

    Re: Delete row if cell J contains any text

    Use:

    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