Greetings Stack Overflow,所以我已经为这个问题经历了很多潜在的解决方案,最终我有了一个经验,无论我的工作簿中的哪个工作表我决定引用我收到错误1004消息。这变得相当令人沮丧,并且想知道这里是否有人可能知道是什么导致了这一点。
'This subroutine will delete the old Report Worksheets and create the new ones which we will have the updated data on what was found.
Sub Create_ReportSheets()
Dim rPI As Range
Dim rFI As Range
Dim rUI As Range
Application.DisplayAlerts = False
On Error Resume Next
Sheets("Passed Inputs").Delete
Sheets("Failed Inputs").Delete
Sheets("Unmatched Inputs").Delete
Application.DisplayAlerts = True
On Error GoTo 0
'Add & Config the new "Pased Inputs" sheet.
Sheets.Add(After:=Sheets("Rule Tables")).Name = "Passed Inputs"
Set rPI = Sheets("Passed Inputs").Range("A0:B0")
以下行是引发错误的原因。我尝试重新启动excel并在新的工作簿中测试它并且没有成功。以前用于定义运行范围的行不能在别处重新执行,如果我尝试将它们复制到其他地方则会开始抛出此错误。
Set rPI = Sheets("Passed Inputs").Range("A0:B0")
答案 0 :(得分:0)
而不是:
Set rPI = Sheets("Passed Inputs").Range("A0:B0")
使用:
Set rPI = Sheets("Passed Inputs").Range("A:B") to select the 2 complete columns.