我有一個超過10,000行的excel文件。我想運行一個VBA腳本,刪除所有列B
結束單詞reduce
中的行。例如,如果我的專欄是這樣的:如果一個單元格以某個單詞結尾,我該如何刪除整行? VBA
CostReduce
PriceReduce
ReducePrice
MaterialReduce
InfrastructureReduce
ReduceProfits
ReduceOverhead
我想腳本運行,刪除具有在Reduce
結尾的單詞中的每一行。因此,輸出將是:
ReducePrice
ReduceProfits
ReduceOverhead
,我現在所擁有的腳本刪除包含單詞減少所有行,我不知道我該怎麼去,因此我想要做什麼改變它。
Sub DeleteReduce()
Dim ContainWord As String
Dim i As Integer
i = 2
ContainWord = "reduce"
Do While Range("B" & i) <> ""
If Not Range("B" & i).Find(ContainWord) Is Nothing Then
Range("B" & i).EntireRow.Delete
Else
i = i + 1
End If
Loop
Range("B2").Select
End Sub
代替你的指令'如果沒有範圍( 「B」 &I).Find(ContainWord)是沒有什麼Then'通過'如果範圍( 「B」 &I),如 「*」 和containword then' – h2so4