Excel精英培训网

 找回密码
 注册
数据透视表40+个常用小技巧,让你一次学会!
查看: 471|回复: 1

各位老师,麻烦帮我看下这个程序有什么问题

[复制链接]
发表于 2024-1-17 17:24 | 显示全部楼层 |阅读模式
我这个程序,是想删除工作簿中所有工作表中,出现“空”的行,但执行的时候,只能删除当前工作表中出现“空”的行,其他工作表删不了,麻烦看看什么问题,感谢!


Sub 删除空行()

Dim ws As Worksheet
Dim lastrow As Long
Dim i As Long

For Each ws In ThisWorkbook.Sheets
lastrow = 10000
For i = lastrow To 1 Step -1
If WorksheetFunction.CountIf(Rows(i), "空") > 0 Then
ws.Rows(i).Delete Shift:=x1up
End If
Next i

Next ws

End Sub
发表于 2024-1-17 23:38 | 显示全部楼层
Sub 删除空行()
    Dim ws As Worksheet
    Dim lastrow As Long
    Dim i As Long
    For Each ws In ThisWorkbook.Sheets
        lastrow = 10000
        For i = lastrow To 1 Step -1
            If WorksheetFunction.CountIf(ws.Rows(i), "空") > 0 Then
                ws.Rows(i).Delete Shift:=x1up
            End If
        Next i
    Next ws
End Sub

评分

参与人数 1学分 +2 收起 理由
18683137373 + 2 学习了

查看全部评分

回复

使用道具 举报

您需要登录后才可以回帖 登录 | 注册

本版积分规则

小黑屋|手机版|Archiver|Excel精英培训 ( 豫ICP备11015029号 )

GMT+8, 2024-4-29 08:20 , Processed in 0.209135 second(s), 6 queries , Gzip On, Yac On.

Powered by Discuz! X3.4

Copyright © 2001-2020, Tencent Cloud.

快速回复 返回顶部 返回列表