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