求excel宏代码:多条件删行,把C列单元格大于0的,A列单元格中包含字符“aa”的,删除整行。vba代码怎么写
3个回答
2013-01-25 · 知道合伙人软件行家
关注
展开全部
Sub test()
Application.ScreenUpdating = False
Dim i As Long
For i = [a65536].End(xlUp).Row To 1 Step -1
If Range("c" & i) > 0 And Range("a" & i) Like "*aa*" Then Rows(i).Delete
Next
Application.ScreenUpdating = True
End Sub
Application.ScreenUpdating = False
Dim i As Long
For i = [a65536].End(xlUp).Row To 1 Step -1
If Range("c" & i) > 0 And Range("a" & i) Like "*aa*" Then Rows(i).Delete
Next
Application.ScreenUpdating = True
End Sub
追问
这三个回答中,你的回答最正确,删行应该倒着删。
如果条件改为:A列单元格中不包含字符“aa”,代码怎么写?
追答
If Range("c" & i) > 0 And not (Range("a" & i) Like "*aa*" ) Then Rows(i).Delete
本回答被提问者采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
dim r
for r=起始行 to 结束行
if cells(r,3)>0 and instr(cells(r,1), "aa")>0 then
rows(r).delete
r=r-1
end if
next r
for r=起始行 to 结束行
if cells(r,3)>0 and instr(cells(r,1), "aa")>0 then
rows(r).delete
r=r-1
end if
next r
追问
如果条件改为:A列单元格中不包含字符“aa”,代码怎么写?
追答
dim r
for r=起始行 to 结束行
if cells(r,3)>0 and instr(cells(r,1), "aa")=0 then
rows(r).delete
r=r-1
end if
next r
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
sub 删行()
dim i as integer
for i = 1 to worksheetfunction.countif(rang("A:A"),"<>"&"")
If cells(i,"A") like "aa" and cells (i,"C")=0 then rows(I).delete
next
end sub
dim i as integer
for i = 1 to worksheetfunction.countif(rang("A:A"),"<>"&"")
If cells(i,"A") like "aa" and cells (i,"C")=0 then rows(I).delete
next
end sub
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询