简体   繁体   English

Macro VBA:我的代码有什么问题? 行删除

[英]Macro VBA : What is wrong with my code ? Row delete

I am trying to delete the entire row if any cell in column A is blank. 我试图删除整行,如果列A中的任何单元格为空。

Also this code should run on two specific sheets only (ie "ATM SLA Availability Report" & "Incident Report") within the same workbook. 同样,此代码应仅在同一工作簿中的两个特定表上运行(即“ ATM SLA可用性报告”和“事件报告”)。

Below is my code. 下面是我的代码。 It gives me Run-Time error 9 when I run it. 当我运行它时,它给我运行时错误9。

Sub test()
    Worksheets("ATM SLA Availability Report").Range("A:A").SpecialCells(xlCellTypeBlanks).EntireRow.Delete shift:=xlUp
    Worksheets("Incident Report").Range("A:A").SpecialCells(xlCellTypeBlanks).EntireRow.Delete shift:=xlUp
End Sub

Run-Time error 9 indicates "Out of Range" meaning that you're trying to reference something that doesn't exist within the worksheet (or workbook), likely from one of your sheet names spelled incorrectly. Run-Time error 9指示“超出范围”,表示您正在尝试引用工作表(或工作簿)中不存在的内容,可能是由于拼写错误的工作表名称之一引起的。

I don't see anything wrong with your code, I've tested it myself and it works fine for me. 我没有发现您的代码有什么问题,我已经对它进行了测试,对我来说很好。 You can check further at which line the code is giving the error by clicking "Debug" when the error pops up. 您可以通过在错误弹出时单击“调试”来进一步检查代码在哪一行给出错误。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM