+ Reply to Thread
Results 1 to 10 of 10

Looping through and deleting rows if cells contain a value

  1. #1
    Registered User
    Join Date
    08-08-2013
    Location
    Texas
    MS-Off Ver
    Excel 2010
    Posts
    46

    Unhappy Looping through and deleting rows if cells contain a value

    hey all,

    I have a normally easy task that is causing me some grief. In column f of my data I either have a number or this "____________". My goal is to delete the entire row if that line is present but my code is not finding that value in my range
    I am wondering is this some format value or something, but it shows up in the formula line as a line. Doesn't appear to be an underline, but I could be wrong. Below is my code.
    Thanks in advance

    Please Login or Register  to view this content.

  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: Looping through and deleting rows if cells contain a value

    Can you attach a sample file with some data?

  3. #3
    Registered User
    Join Date
    08-08-2013
    Location
    Texas
    MS-Off Ver
    Excel 2010
    Posts
    46

    Re: Looping through and deleting rows if cells contain a value

    Sure thing. See below.

    coursetest2.xlsx

  4. #4
    Forum Expert
    Join Date
    10-06-2008
    Location
    Canada
    MS-Off Ver
    2007 / 2013
    Posts
    5,753

    Re: Looping through and deleting rows if cells contain a value

    What do you get when you run this?. Underscore is Char95.
    Change the A12 reference to the cell with the characters to be deleted.

    Please Login or Register  to view this content.

  5. #5
    Forum Expert
    Join Date
    10-06-2008
    Location
    Canada
    MS-Off Ver
    2007 / 2013
    Posts
    5,753

    Re: Looping through and deleting rows if cells contain a value

    They are underscores (Char95)
    So you'll have to delete Char95's

  6. #6
    Forum Expert
    Join Date
    10-06-2008
    Location
    Canada
    MS-Off Ver
    2007 / 2013
    Posts
    5,753

    Re: Looping through and deleting rows if cells contain a value

    Not very fast but it should delete all the underscores (if there are 12 in a cell).
    Instead of the "Delete Shift:=xlUp" you can of course also use "ClearContents"
    Try it on a copy of your workbook first though.
    Good luck.

    Please Login or Register  to view this content.

  7. #7
    Forum Expert
    Join Date
    06-12-2012
    Location
    Ridgefield Park, New Jersey
    MS-Off Ver
    Excel 2003,2007,2010
    Posts
    10,241

    Re: Looping through and deleting rows if cells contain a value

    Maybe:

    Please Login or Register  to view this content.

  8. #8
    Registered User
    Join Date
    04-02-2014
    Location
    Chicago
    MS-Off Ver
    Excel 2007
    Posts
    3

    Re: Looping through and deleting rows if cells contain a value

    Try looking for the string length instead. It looks like your using a fixed string length of 12 characters.

    Please Login or Register  to view this content.

  9. #9
    Registered User
    Join Date
    04-02-2014
    Location
    Chicago
    MS-Off Ver
    Excel 2007
    Posts
    3

    Re: Looping through and deleting rows if cells contain a value

    Try looking for the string length instead. It looks like your using a fixed string length of 12 characters.

    Please Login or Register  to view this content.

  10. #10
    Registered User
    Join Date
    08-08-2013
    Location
    Texas
    MS-Off Ver
    Excel 2010
    Posts
    46

    Re: Looping through and deleting rows if cells contain a value

    Thank you all. That helped me get over the hump. Got it working now.

+ 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. Keep certain rows and deleting certain cells
    By siroco79 in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 12-02-2013, 02:37 PM
  2. Multiple categories, Looping iterations and deleting rows
    By Glenn Kennedy in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 09-04-2012, 06:46 AM
  3. VBA- deleting rows which contain cells that meet criteria, but skip alpha rows
    By cheapkid1 in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 08-30-2012, 08:49 AM
  4. Merging cells from next rows, then deleting the rows
    By grinder in forum Excel - New Users/Basics
    Replies: 3
    Last Post: 08-18-2010, 01:52 PM
  5. looping through and deleting rows
    By Ricardo9211 in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 09-03-2009, 08:18 PM

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