VBA -excel --遍历行


Sub filter1()
Rem MsgBox ("AAAAA")
Rem 1 get selected zone
Rem 2 loop rows and check column
Rem 3 if true then hide it

 

Dim pos, total

Rem 获取行数
total = Sheet1.UsedRange.Rows.Count

Rem 开始循环
For pos = 1 To Sheet1.UsedRange.Rows.Count
Dim tmpStr

Rem B 列示第二列
tmpStr = Cells(pos, 2)
If InStr(tmpStr, "其他") Then
Range(Cells(pos, 1), Cells(total, 1)).EntireRow.Hidden = True

Exit Sub
End If

Rem MsgBox (tmpStr)
Next


End Sub


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM