如何删除基于 J 列 = 0 内发布的行?

发布于 2024-12-11 17:07:31 字数 199 浏览 0 评论 0原文

我在 Excel 电子表格中有以下内容

a cut down version of my electronics

如何根据其中发布的内容删除行J 列 = 0?

最好剪切该行并将其粘贴到另一张纸中。但是如果您可以帮助我删除它,那就太好了。

I have the following in Excel spreadsheet,

a cut down version of my spreadsheet

How do I delete a row based on the published within the J column = 0?

It would be better to cut the row and paste it within another sheet.. but IF you can help me with just deleting it, that would be good.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

不奢求什么 2024-12-18 17:07:31

此代码自动筛选活动工作表上 J = 0 的行,将它们复制到第二个工作表上的第一个空白行,然后从活动工作表中删除这些行。

更改此行 Set ws2 = Sheets(2) 将行复制到不同的工作表,即 Set ws2 = Sheets("Your Sheet Name")Set ws2 = Sheets(5) 第五张纸等

Sub MoveEm()
    Dim ws1 As Worksheet
    Dim ws2 As Worksheet
    Set ws1 = ActiveSheet
    Set ws2 = Sheets(2)
    Dim rng1 As Range
    Application.ScreenUpdating = False
    With ws1
        .AutoFilterMode = False
        .Columns("j").AutoFilter Field:=1, Criteria1:="0"
        With .AutoFilter.Range.Offset(1, 0).EntireRow
        Set rng1 = ws2.Cells.Find("*", ws2.[a1], xlValues, , xlRows, xlPrevious)
        If rng1 Is Nothing Then
        Set rng1 = ws2.[a1]
        Else
        Set rng1 = ws2.Cells(rng1.Row + 1, "A")
        End If
            .Copy rng1
            .Delete
        End With
        .AutoFilterMode = False
    End With
    Application.ScreenUpdating = True
End Sub

This code autofilters the rows on the activesheet where J =0, copies them to the first blank row on the second worksheet, then deletes the rows from the activesheet.

Change this line Set ws2 = Sheets(2) to copy the rows to a different sheet, ie Set ws2 = Sheets("Your Sheet Name") or Set ws2 = Sheets(5) for the fifth sheet etc

Sub MoveEm()
    Dim ws1 As Worksheet
    Dim ws2 As Worksheet
    Set ws1 = ActiveSheet
    Set ws2 = Sheets(2)
    Dim rng1 As Range
    Application.ScreenUpdating = False
    With ws1
        .AutoFilterMode = False
        .Columns("j").AutoFilter Field:=1, Criteria1:="0"
        With .AutoFilter.Range.Offset(1, 0).EntireRow
        Set rng1 = ws2.Cells.Find("*", ws2.[a1], xlValues, , xlRows, xlPrevious)
        If rng1 Is Nothing Then
        Set rng1 = ws2.[a1]
        Else
        Set rng1 = ws2.Cells(rng1.Row + 1, "A")
        End If
            .Copy rng1
            .Delete
        End With
        .AutoFilterMode = False
    End With
    Application.ScreenUpdating = True
End Sub
甜心 2024-12-18 17:07:31
Sub Delete_Zero_Codes()  ' Deletes The Zero  Codes 
    Dim rCell As Range
    Dim strAddress As String
Application.ScreenUpdating = False

    With Thisworkbook.Sheets("sheetname").Columns("J")
        Set rCell = .Find(What:=0, LookIn:=xlValues, LookAt:=xlWhole, SearchOrder:=xlByColumns)
        If Not rCell Is Nothing Then
            Do
            strAddress = rCell.Address
            rCell.EntireRow.Delete
            Set rCell = .FindNext(Range(strAddress))
            Loop Until rCell Is Nothing
        End If
    End With

Application.ScreenUpdating = True

End Sub

这些宏删除 J 列的零代码,并且不会将它们粘贴到其他工作表,如果您需要将 J 列的零代码复制到其他工作表,请告诉我,我会更新它

Sub Delete_Zero_Codes()  ' Deletes The Zero  Codes 
    Dim rCell As Range
    Dim strAddress As String
Application.ScreenUpdating = False

    With Thisworkbook.Sheets("sheetname").Columns("J")
        Set rCell = .Find(What:=0, LookIn:=xlValues, LookAt:=xlWhole, SearchOrder:=xlByColumns)
        If Not rCell Is Nothing Then
            Do
            strAddress = rCell.Address
            rCell.EntireRow.Delete
            Set rCell = .FindNext(Range(strAddress))
            Loop Until rCell Is Nothing
        End If
    End With

Application.ScreenUpdating = True

End Sub

These macro deletes zero codes of J column and does not paste them to other sheet, if you need zero codes of J column to be copied to other sheet then let me know i will update it

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文