+ Reply to Thread
Results 1 to 5 of 5

Delete row if column contains string

  1. #1
    Registered User
    Join Date
    11-21-2007
    Posts
    3

    Delete row if column contains string

    I cannot get the following code to do what I want

    Please Login or Register  to view this content.
    I want to go through rows 4 to 517 and see if column M (= column 13) contains the string 'ADH'. If it does, nothing should happen. If it does not, the row should be entirely deleted.
    The value in column M could be something like 'BBR, ADH, HE' or 'KFE' or 'BH, HE'.

    Any help will be greatly appreciated.

  2. #2
    Registered User
    Join Date
    10-09-2007
    Posts
    8
    Does it even get into the if statement? Place a break point inside the if statement to see if it even gets in there.

  3. #3
    Registered User
    Join Date
    11-21-2007
    Posts
    3
    It does get in the If statement, but it doesn't remove lines consistently. It seems to remove lines at random.

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

    Please Login or Register  to view this content.
    Hope that helps.

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

    Free DataBaseForm example

  5. #5
    Registered User
    Join Date
    11-21-2007
    Posts
    3
    This worked for me

    Please Login or Register  to view this content.
    with Cells(1,2).Value instead of "ADH" and the removal of rows where column M is empty.

+ 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