三九宝宝网宝宝百科宝宝知识

求教excel中使用VB代码删除每个sheet中某个列中值为特定值的一整行

01月07日 编辑 39baobao.com

为了验证代码是否获得除了sheet1表以外的其它表:

Sub wfdele()

Dim sh As Worksheet

Dim c As Long

Dim r As Long

Dim LastRow As Integer

Dim Lastcolumn As Integer

For Each sh In Worksheets

debug.print sh.name '增加的代码

Lastcolumn = sh.[IV1].End(xlToLeft).Column

LastRow = sh.[a65536].End(xlUp).Row

For c = 1 To Lastcolumn

If sh.Cells(1, c).Value = "b" Then

For r = LastRow To 1 Step -1

If sh.Cells(r, c).Value = "0" Then

Range(r & ":" & r).Delete shift:=xlUp

End If

Next

End If

Next

Next

End Sub

推荐阅读
图文推荐