+ Reply to Thread
Results 1 to 4 of 4

empty autofiltered range

  1. #1
    Stefi
    Guest

    empty autofiltered range

    Hi All,
    I use the following piece of code (I don't repeat here the declarations):

    For each cella in otherrng
    Range("A1").Select
    Selection.AutoFilter Field:=2, Criteria1:=cella
    Set txtteljes = ActiveSheet.AutoFilter.Range.Rows
    Set txtteljes = txtteljes.Offset(1, 0).Resize(txtteljes.Rows.Count -
    1, txtteljes.Columns.Count)
    On Error Resume Next
    Set txtszurt = txtteljes.SpecialCells(xlVisible)
    On Error GoTo 0
    If Not txtszurt Is Nothing Then
    Selection.Delete Shift:=xlUp
    End If
    Selection.AutoFilter
    Next

    My problem is that when range txtszurt is empty (I see on the screen that no
    rows are selected), the
    If Not txtszurt Is Nothing Then
    condition is still met, and all rows are deleted.
    What's wrong?

    Regards,
    Stefi



  2. #2
    Dave Peterson
    Guest

    Re: empty autofiltered range

    You have a response at your other post.

    Stefi wrote:
    >
    > Hi All,
    > I use the following piece of code (I don't repeat here the declarations):
    >
    > For each cella in otherrng
    > Range("A1").Select
    > Selection.AutoFilter Field:=2, Criteria1:=cella
    > Set txtteljes = ActiveSheet.AutoFilter.Range.Rows
    > Set txtteljes = txtteljes.Offset(1, 0).Resize(txtteljes.Rows.Count -
    > 1, txtteljes.Columns.Count)
    > On Error Resume Next
    > Set txtszurt = txtteljes.SpecialCells(xlVisible)
    > On Error GoTo 0
    > If Not txtszurt Is Nothing Then
    > Selection.Delete Shift:=xlUp
    > End If
    > Selection.AutoFilter
    > Next
    >
    > My problem is that when range txtszurt is empty (I see on the screen that no
    > rows are selected), the
    > If Not txtszurt Is Nothing Then
    > condition is still met, and all rows are deleted.
    > What's wrong?
    >
    > Regards,
    > Stefi


    --

    Dave Peterson

  3. #3
    Forum Contributor
    Join Date
    06-10-2005
    Location
    Central Jersey
    Posts
    117
    could you provide some test data please??? And some expected solutions.
    -Joseph

  4. #4
    Stefi
    Guest

    Re: empty autofiltered range

    I repeat here Dave Peterson's solution:
    Put line
    Set szurtrng = Nothing
    before
    On Error Resume Next
    statement!
    Stefi


    „malik641” ezt *rta:

    >
    > could you provide some test data please??? And some expected solutions.
    >
    >
    > --
    > malik641
    >
    >
    > ------------------------------------------------------------------------
    > malik641's Profile: http://www.excelforum.com/member.php...o&userid=24190
    > View this thread: http://www.excelforum.com/showthread...hreadid=390532
    >
    >


+ 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