Consulting

Results 1 to 3 of 3

Thread: Deleting the row that contain the text " Dismantle"

  1. #1

    Deleting the row that contain the text " Dismantle"

    Dear All,

    Attached file is for ref.

    As per text in column v i want a macro or code that if text "DISMANTLE" is encountered then delete the row.
    else do nothing.
    The column V contains the Text " Dismantle" and otherwise.
    Note:- In filtering mode deleting the rows consisting dismantle is tedious and risky if the data is two huge.
    So I'm looking alternative and safe option.
    Please assist?

    Rgds,
    Aligahk06

  2. #2
    Administrator
    VP-Knowledge Base
    VBAX Grand Master mdmackillop's Avatar
    Joined
    May 2004
    Location
    Scotland
    Posts
    14,489
    Location
    I don't see any of your code to assist with (see here). If it helps, I would still use Autofilter in creating a solution.
    MVP (Excel 2008-2010)

    Post a workbook with sample data and layout if you want a quicker solution.


    To help indent your macros try Smart Indent

    Please remember to mark threads 'Solved'

  3. #3
    Distinguished Lord of VBAX VBAX Grand Master Bob Phillips's Avatar
    Joined
    Apr 2005
    Posts
    25,453
    Location
    [vba]

    Sub DeleteData()
    Dim LastRow As Long
    Dim rng As Range

    With ActiveSheet

    LastRow = .Cells(.Rows.Count, "V").End(xlUp).Row
    Set rng = .Range("A9:X" & LastRow)
    rng.AutoFilter Field:=22, Criteria1:="DISMANTLE"
    On Error Resume Next
    .Rows(9).Hidden = True
    Set rng = rng.SpecialCells(xlCellTypeVisible)
    On Error GoTo 0

    If Not rng Is Nothing Then rng.EntireRow.Delete
    .Rows(9).Hidden = False
    .Rows(9).AutoFilter Field:=22, Criteria1:="*"
    End With
    End Sub
    [/vba]
    ____________________________________________
    Nihil simul inventum est et perfectum

    Abusus non tollit usum

    Last night I dreamed of a small consolation enjoyed only by the blind: Nobody knows the trouble I've not seen!
    James Thurber

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •