+ Reply to Thread
Results 1 to 5 of 5

Delete all rows with the data "06 - DEAD" in column H

Hybrid View

  1. #1
    Registered User
    Join Date
    01-06-2008
    Posts
    5

    Delete all rows with the data "06 - DEAD" in column H

    Can Someone help me out with a macro.

    I need a macro to delete all rows with the data "06 - DEAD" in column H

    Would really appreciate if someone could help me out with this.

  2. #2
    Forum Contributor VBA Noob's Avatar
    Join Date
    04-25-2006
    Location
    London, England
    MS-Off Ver
    xl03 & xl 07(Jan 09)
    Posts
    11,988
    Try

    Sub DeleteColH()
    
        Columns("H:H").AutoFilter Field:=1, Criteria1:="06 - DEAD"
        Range("H1").Offset(1, 0).Resize(Cells(Rows.Count, "H").End(xlUp).Row) _
        .EntireRow.Delete
        ActiveSheet.AutoFilterMode = False
    End Sub
    VBA Noob
    _________________________________________


    Credo Elvem ipsum etian vivere
    _________________________________________
    A message for cross posters

    Please remember to wrap code.

    Forum Rules

    Please add to your signature if you found this link helpful. Excel links !!!

  3. #3
    Forum Contributor VBA Noob's Avatar
    Join Date
    04-25-2006
    Location
    London, England
    MS-Off Ver
    xl03 & xl 07(Jan 09)
    Posts
    11,988
    Or Royuk likes using the below union method

    Sub deleteRows()
        Dim cl     As Range
        Dim rng    As Range
        Dim R      As Long
        Dim X      As Long
    
        R = ActiveSheet.Cells(Rows.Count, "H").End(xlUp).Row
        For X = 1 To R
            If Not IsEmpty(Cells(X, "H")) And Cells(X, "H").Value = "06 - DEAD" Then
                If rng Is Nothing Then
                    Set rng = Cells(X, "H")
                Else: Set rng = Union(rng, Cells(X, "H"))
                End If
            End If
        Next X
        rng.EntireRow.Delete
    End Sub
    VBA Noob

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

    Your code should be pretty quick so long as the data is in a filterable format.
    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
    01-06-2008
    Posts
    5
    Thanks a lot!!!!

+ 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