Excel精英培训网

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

[已解决]变更条件列,求修改代码

[复制链接]
发表于 2016-6-3 12:05 | 显示全部楼层 |阅读模式
变更条件列,求修改代码
最佳答案
2016-6-3 16:24
Sub rtian2()
a = Sheet4.Range("a5:m" & Sheet4.[a65536].End(xlUp).Row)
b = Sheet4.Range("a5:m" & Sheet4.[a65536].End(xlUp).Row)
c = ",1,2,3,"
    For i = 1 To UBound(a)
        If InStr(c, "," & a(i, 3) & ",") = 0 And a(i, 1) <> "" Then
            n = n + 1
            For j = 1 To UBound(a, 2)
                b(n, j) = a(i, j)
            Next
        End If
    Next
Sheet4.Range("a5:m" & Sheet4.[a65536].End(xlUp).Row).ClearContents
If n > 0 Then Sheet4.Range("a5:m" & n + 4) = b
End Sub

符合对应行条件删除3.zip

31.34 KB, 下载次数: 15

excel精英培训的微信平台,每天都会发送excel学习教程和资料。扫一扫明天就可以收到新教程
发表于 2016-6-3 16:24 | 显示全部楼层    本楼为最佳答案   
Sub rtian2()
a = Sheet4.Range("a5:m" & Sheet4.[a65536].End(xlUp).Row)
b = Sheet4.Range("a5:m" & Sheet4.[a65536].End(xlUp).Row)
c = ",1,2,3,"
    For i = 1 To UBound(a)
        If InStr(c, "," & a(i, 3) & ",") = 0 And a(i, 1) <> "" Then
            n = n + 1
            For j = 1 To UBound(a, 2)
                b(n, j) = a(i, j)
            Next
        End If
    Next
Sheet4.Range("a5:m" & Sheet4.[a65536].End(xlUp).Row).ClearContents
If n > 0 Then Sheet4.Range("a5:m" & n + 4) = b
End Sub

评分

参与人数 1 +1 收起 理由
yiniuniu + 1 学习了,谢谢!

查看全部评分

回复

使用道具 举报

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

本版积分规则

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

GMT+8, 2024-5-15 00:49 , Processed in 0.280573 second(s), 14 queries , Gzip On, Yac On.

Powered by Discuz! X3.4

Copyright © 2001-2020, Tencent Cloud.

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