Results 1 to 3 of 3

Thread: by vba code filter and delete rows

  1. #1

    Thread Starter
    Lively Member
    Join Date
    Jul 2006
    Posts
    97

    by vba code filter and delete rows

    Hi friends

    I am trying to filter rows by value which is available in cell (as a variable) then after result returned I want to delete these rows by vba.

    thank you

  2. #2
    Just a Member! seenu_1st's Avatar
    Join Date
    Aug 2007
    Location
    India
    Posts
    2,170

    Re: by vba code filter and delete rows

    u can loop rows using For Next loop method, load result row numbers in an array, then u can delete rows using the same loop by array.
    Seenu

    If this post is useful, pls don't forget to Rate this post.
    Pls mark thread as resolved once ur problem solved.
    ADO Tutorial Variable types SP6 for VB6, MsFlexGrid fast fill, Sorting Algorithms


  3. #3
    New Member
    Join Date
    Jun 2011
    Posts
    4

    Re: by vba code filter and delete rows

    Try Below Code

    Change Range According to data.

    Code:
    Sub deleteValue()
        Dim deleteValue As String
        
        deleteValue = "Enter Delete Value"
        Range("A1").Select
          Range(Selection, Selection.End(xlToRight)).Select
        Selection.AutoFilter Field:=1, Criteria1:="DeleteValue"
        Range("A1").Select
        ActiveCell.Offset(1, 0).Select
        Range(Selection, Selection.End(xlDown)).EntireRow.Delete
        Range("A1").Select
        Range("A1").AutoFilter
        
    End Sub

Posting Permissions

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



Click Here to Expand Forum to Full Width