+ Reply to Thread
Results 1 to 6 of 6

Delete rows fi specific text

Hybrid View

  1. #1
    Forum Contributor
    Join Date
    03-14-2012
    Location
    location
    MS-Off Ver
    Excel 2007
    Posts
    170

    Delete rows fi specific text

    Hi,

    I tried several ways to delete the rows containing specific words but I can't...:
    in col A: range("A5:A200")

    Input Values:
    Carrier Selected: All Carriers
    Show STC: OFF
    Priority: OFF

    in col B:range("b5:b200)
    LOA
    LOB
    LOC
    LOD
    LOE
    LOF
    LOG
    LOH
    LOI
    OMT


    Thank you very much for your help!
    blue

  2. #2
    Forum Expert Pepe Le Mokko's Avatar
    Join Date
    05-14-2009
    Location
    Belgium
    MS-Off Ver
    O365 v 2504
    Posts
    13,621

    Re: Delete rows fi specific text

    care to elaborate? Clear as mud to me

  3. #3
    Forum Contributor
    Join Date
    03-14-2012
    Location
    location
    MS-Off Ver
    Excel 2007
    Posts
    170

    Re: Delete rows fi specific text

    Hi Pepe Le Mokko,
    thx!
    it takes too much time to do it what I tried
    '
    '
      Dim Lastrow As Long
    Lastrow = Range("b150").End(xlUp).Row
    Dim X As Long
    For X = Lastrow To 5 Step -1
    '*****delete a/c type
    If Range("b" & X).Text = "Input Values:" Then
    Range("b" & X).EntireRow.Delete
    End If
    '
    'and so on for each case...

  4. #4
    Forum Expert millz's Avatar
    Join Date
    08-14-2013
    Location
    Singapore
    MS-Off Ver
    Excel, Access 2016
    Posts
    1,694

    Re: Delete rows fi specific text

    If I understand what you want... :
    Sub DeleteRow()
        Set r = Range("A5:A200")
        For Each c In r
            If InStr(1, c.Value, "Input Values:", vbTextCompare) > 0 Or InStr(1, c.Value, "Carrier Selected: All Carriers", vbTextCompare) > 0 Or _
            InStr(1, c.Value, "Input Values:", vbTextCompare) > 0 Or InStr(1, c.Value, "Input Values:", vbTextCompare) > 0 Then
                c.Delete shift:=xlUp    ' Use this if you only want to delete the cell column A
                rows(c.row & ":" & c.row).Delete shift:=xlUp ' Use this if you want to delete the entire row
            End If
        Next c
        Set r = Range("B5:B200")
        For Each c In r
            If InStr(1, c.Value, "LOA", vbTextCompare) > 0 Or _
            InStr(1, c.Value, "LOB", vbTextCompare) > 0 Or _
            InStr(1, c.Value, "LOC", vbTextCompare) > 0 Or _
            InStr(1, c.Value, "LOD", vbTextCompare) > 0 Or _
            InStr(1, c.Value, "LOE", vbTextCompare) > 0 Or _
            InStr(1, c.Value, "LOF", vbTextCompare) > 0 Or _
            InStr(1, c.Value, "LOG", vbTextCompare) > 0 Or _
            InStr(1, c.Value, "LOH", vbTextCompare) > 0 Or _
            InStr(1, c.Value, "LOI", vbTextCompare) > 0 Or _
            InStr(1, c.Value, "OMT", vbTextCompare) > 0 Then
                c.Delete shift:=xlUp    ' Use this if you only want to delete the cell column B
                rows(c.row & ":" & c.row).Delete shift:=xlUp ' Use this if you want to delete the entire row
            End If
        Next c
    End Sub

  5. #5
    Forum Contributor
    Join Date
    03-14-2012
    Location
    location
    MS-Off Ver
    Excel 2007
    Posts
    170

    Re: Delete rows fi specific text

    Thx millz,

    I 'll try the solution and back to you soon!

  6. #6
    Forum Contributor
    Join Date
    03-14-2012
    Location
    location
    MS-Off Ver
    Excel 2007
    Posts
    170

    Re: Delete rows fi specific text

    Solved! rep added!
    Thank you!

+ 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. Delete / Keep rows containing specific text.
    By fluteloop in forum Excel Programming / VBA / Macros
    Replies: 13
    Last Post: 09-30-2014, 06:48 PM
  2. [SOLVED] delete rows that do not contain the text from a specific cell
    By Vogelmann in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 10-11-2012, 03:10 AM
  3. [SOLVED] Delete rows that do not contain specific text
    By jahburt in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 10-03-2012, 04:14 PM
  4. [SOLVED] Delete Rows With Specific Text
    By Sean in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 08-19-2006, 10:50 AM
  5. Delete rows with specific text
    By MAYDAY in forum Excel Programming / VBA / Macros
    Replies: 8
    Last Post: 06-08-2005, 11:05 AM

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