过滤数据需要删除代码错误 [英] Filter Data Need to Remove Code Error

查看:116
本文介绍了过滤数据需要删除代码错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用以下代码过滤数据删除 在excel但我得到运行时错误1004

i am using below code for filter data remove  in excel but I am getting run time error 1004

Sub Remove()

    'Last Row
        lrow = Range("A" & Rows.Count).End(xlUp).Row
    If lrow = 1 Then ' Change 1 to your header row number
            ' MsgBox "No Data available based on your current filter"
    Selection.AutoFilter
    Exit Sub
        End If
            With ActiveSheet.AutoFilter.Range
        'First Row
        frow = .Offset(1).Resize(.Rows.Count - 1, .Columns.Count).SpecialCells(xlCellTypeVisible).Row
    End With
    
    Rows(frow & ":" & lrow).Select
    Selection.SpecialCells(xlCellTypeVisible).Select
    Selection.Delete Shift:=xlUp
    Selection.AutoFilter
End Sub

Sub Remove()

   With ActiveSheet.AutoFilter.Range
         'First Row
            'frow = .Offset(1).Resize(.Rows.Count - 1, .Columns.Count).SpecialCells(xlCellTypeVisible).Row
     End With
     'Last Row
        lrow = Range("A" & Rows.Count).End(xlUp).Row
         
     Rows(frow & ":" & lrow).Select
     Selection.SpecialCells(xlCellTypeVisible).Select
     Selection.Delete Shift:=xlUp
     
End Sub

DushYant'




推荐答案

抱歉,这不是VBA论坛。 您需要在Excel VBA开发人员论坛中发帖以获取VBA的帮助。

Sorry but this is not a VBA forum.  You will need to post in the Excel VBA Developers forum for help with VBA.

请务必发布完整的错误消息,因为错误没有帮助。

Be sure to post the complete error message as just the error is of no help.


这篇关于过滤数据需要删除代码错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆