为什么我的宏不会删除所有行(VBA) [英] Why my macro doesn't delete all the rows (VBA)
本文介绍了为什么我的宏不会删除所有行(VBA)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
Sub Macro1()
Dim a As Range
设置a = Hoja1 .Range(A1:A12)
对于每个单元格在
中如果cell.Interior.ColorIndex = xlNone然后
cell.EntireRow.Delete
End If
Next
End Sub
解决方案
code> Sub Macro1()
Dim a As Range,x As Long
设置a = Hoja1.Range(A1:A12)
对于x = a.cells.count到1 Step -1
with a.cells(x)
if .Interior.ColorIndex = xlNone Then .EntireRow.Delete
End With
Next x
End Sub
i have this macro it is supposed to delete all the cells that doesnt have a background set to them, but when I execute the macro if two or more contiguous cells doesnt have a background it only deletes one of them, here is the code:
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
解决方案
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
这篇关于为什么我的宏不会删除所有行(VBA)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文