- 帖子
- 455
- 主題
- 111
- 精華
- 0
- 積分
- 563
- 點名
- 197
- 作業系統
- Windows 10
- 軟體版本
- Office 2019
- 閱讀權限
- 50
- 性別
- 男
- 註冊時間
- 2013-11-7
- 最後登錄
- 2026-10-30
         
|
可否簡化 VBA 語法
大家好,我寫一串語法
但自覺得過程太冗長,是否可以簡化程式語法
條件1.在A欄位,只要出現是"空白",就整列移除
條件2.在A欄位,只要出現這些英文,就整列移除 : TPD . TPD-both . TPD-viewing . GSA
Sub Step1()
On Error Resume Next
[A:A].SpecialCells(xlCellTypeBlanks).EntireRow.Delete
On Error GoTo 0
End Sub
Sub Step2()
Dim yy
yy = "TPD"
For I = [a65536].End(xlUp).Row To 1 Step -1
If WorksheetFunction.CountIf(Rows(I), yy) > 0 Then Rows(I).Delete
Next I
End Sub
Sub Step3()
Dim yy
yy = "TPD-both"
For I = [a65536].End(xlUp).Row To 1 Step -1
If WorksheetFunction.CountIf(Rows(I), yy) > 0 Then Rows(I).Delete
Next I
End Sub
Sub Step4()
Dim yy
yy = "TPD-viewing"
For I = [a65536].End(xlUp).Row To 1 Step -1
If WorksheetFunction.CountIf(Rows(I), yy) > 0 Then Rows(I).Delete
Next I
End Sub
Sub Step5()
Dim yy
yy = "GSA"
For I = [a65536].End(xlUp).Row To 1 Step -1
If WorksheetFunction.CountIf(Rows(I), yy) > 0 Then Rows(I).Delete
Next I
End Sub
在麻煩各位先進! |
|