我一直在尋找使用此If/Or語句的更短的方法,但無濟於事。VBA - 更短的If/Or語句
Sheets("Raw").Select
Dim rowCount As Integer, rows As Integer
rows = 0
Dim CRC As String
rowCount = Range("I2", Range("I2").End(xlDown)).rows.Count
For rows = 1 To rowCount
Range("I1").Offset(rows, 0).Select
CRC = ActiveCell.Value
If CRC = "Admin Cancellation" _
Or CRC = "Building sold/Management Co changed" _
Or CRC = "Contract Renewal delayed" _
Or CRC = "System decommissioned" _
Or CRC = "Building demolished" _
Or CRC = "cancelled due to credit hold/risk" Then
ActiveCell.rows.EntireRow.Select
Selection.Delete Shift:=xlUp
rows = rows - 1
rowCount = rowCount - 1
End If
Next rows
在此先感謝!
當您迭代行並刪除行時...您想從下往上....不是自上而下。 – Rdster