我有这个宏它应该删除没有背景设置的所有单元格,但是当我执行宏时如果两个或多个连续单元格没有背景它只删除其中一个,这里是代码:
Sub Macro1()
Dim a As Range
Set a = Hoja1.Range("A1:A12")
For Each cell In a
If cell.Interior.ColorIndex = xlNone Then
cell.EntireRow.Delete
End If
Next
End Sub
答案 0 :(得分:4)
Sub Macro1()
Dim a As Range, x As Long
Set a = Hoja1.Range("A1:A12")
For x = a.cells.count to 1 Step -1
with a.cells(x)
if .Interior.ColorIndex = xlNone Then .EntireRow.Delete
End With
Next x
End Sub