【发布时间】:2016-01-02 15:39:33
【问题描述】:
这就是我的数据的样子。它是另一张纸的摘要。
代码似乎可以运行并执行我需要的操作,如果有 0 值,则扫描 Co B 并删除,如果下面的行不同,则扫描 Col I 并插入行,然后对 Col H 重复。但是我得到一个“运行时1004 application-defined or object defined error”消息而不是刚刚结束的宏。接受任何修改或建议
Range("A100000").End(xlUp).Activate
Range("N1") = ActiveCell.Row
For lRow = Cells(Cells.Rows.Count, "b").End(xlUp).Row To 1 Step -1
If Cells(lRow, "b") = 0 Then
Rows(lRow).EntireRow.Delete
End If
Next lRow
For lRow = Cells(Cells.Rows.Count, "I").End(xlUp).Row To 1 Step -1
If Cells(lRow, "I") <> Cells(lRow - 1, "I") Then '<~~ debugger highlights this line or the other version of this eq below
Rows(lRow).EntireRow.Insert
End If
Next lRow
For lRow = Cells(Cells.Rows.Count, "H").End(xlUp).Row To 1 Step -1
If Cells(lRow, "H") <> Cells(lRow - 1, "H") Then
Rows(lRow).EntireRow.Insert
End If
Next lRow
Range("A1").Activate
Application.ScreenUpdating = True
End Sub
【问题讨论】:
标签: vba excel if-statement runtime-error