Excel 运行比较时 提示 “运行时错误 ‘1004’;方法‘Range’作用于对象‘_Worksheet’时失败”

Excel运行比较时提示“运行时错误‘1004’;方法‘Range’作用于对象‘_Worksheet’时失败”下面是调试代码:SubInterface1()t=Sheet... Excel 运行比较时 提示 “运行时错误 ‘1004’;方法‘Range’作用于对象‘_Worksheet’时失败”
下面是调试代码:
Sub Interface1()
t = Sheet4.Range("v1")
Sheet4.Range("A1:U" & t).Copy
Sheet6.Range("A1:U" & t).PasteSpecial
End Sub
Sub Interface2()
t = Sheet1.Range("f1")
Sheet1.Range("A1:AE" & t).Copy
Sheet7.Range("B1:AF" & t).PasteSpecial
End Sub
Sub comparison()
t = Sheet6.Range("bc1")
For i = 2 To t
Sheet5.Cells(i, 1) = Sheet1.Cells(1, 2)
Sheet5.Cells(i, 2) = Sheet1.Cells(1, 4)
Sheet5.Cells(i, 3) = Sheet6.Cells(i, 22)
Sheet5.Cells(i, 4) = Sheet6.Cells(i, 1)
Sheet5.Cells(i, 5) = Sheet6.Cells(i, 27)
Sheet5.Cells(i, 6) = Sheet6.Cells(i, 28)
Sheet5.Cells(i, 7) = Sheet6.Cells(i, 29)
Sheet5.Cells(i, 8) = Sheet6.Cells(i, 30)
Sheet5.Cells(i, 9) = Sheet6.Cells(i, 31)
Sheet5.Cells(i, 10) = -Sheet6.Cells(i, 45) + Sheet6.Cells(i, 6)
Sheet5.Cells(i, 11) = -Sheet6.Cells(i, 46) + Sheet6.Cells(i, 7)
Sheet5.Cells(i, 12) = -Sheet6.Cells(i, 47) + Sheet6.Cells(i, 8)
Sheet5.Cells(i, 13) = -Sheet6.Cells(i, 48) + Sheet6.Cells(i, 9)
Sheet5.Cells(i, 14) = -Sheet6.Cells(i, 49) + Sheet6.Cells(i, 10)
Sheet5.Cells(i, 15) = -Sheet6.Cells(i, 50) + Sheet6.Cells(i, 11)
Sheet5.Cells(i, 16) = -Sheet6.Cells(i, 51) + Sheet6.Cells(i, 12)
Sheet5.Cells(i, 17) = -Sheet6.Cells(i, 52) + Sheet6.Cells(i, 13)
Sheet5.Cells(i, 18) = -Sheet6.Cells(i, 53) + Sheet6.Cells(i, 14)
Sheet5.Cells(i, 19) = -Sheet6.Cells(i, 54) + Sheet6.Cells(i, 15)
Sheet5.Cells(i, 20) = IIf(Sheet6.Cells(i, 16) = "", 0, Sheet6.Cells(i, 16))
Sheet5.Cells(i, 21) = IIf(Sheet6.Cells(i, 17) = "", 0, Sheet6.Cells(i, 17))
Sheet5.Cells(i, 22) = Sheet6.Cells(i, 18) - Sheet6.Cells(i, 32)
Sheet5.Cells(i, 24) = Sheet6.Cells(i, 19) - Sheet6.Cells(i, 35) - Sheet6.Cells(i, 36) - Sheet6.Cells(i, 37) - Sheet6.Cells(i, 38) - Sheet6.Cells(i, 39) - Sheet6.Cells(i, 40)
Sheet5.Cells(i, 25) = Sheet6.Cells(i, 20) - Sheet6.Cells(i, 41) - Sheet6.Cells(i, 44)
Sheet5.Cells(i, 26) = Sheet6.Cells(i, 21) - (Sheet6.Cells(i, 42) - Sheet6.Cells(i, 43))
Next i
Sheet5.Range("A2:C" & t).Copy
Sheet2.Range("A3:C" & (t + 1)).PasteSpecial
Sheet5.Range("E2:U" & t).Copy
Sheet2.Range("D3:T" & (t + 1)).PasteSpecial
End Sub

Sub result()
t4 = IIf(Sheet2.Range("u1") > 3, Sheet2.Range("u1"), 3)
t1 = Sheet1.Range("f1")
t2 = Sheet4.Range("v1")
t3 = IIf(Sheet5.Range("aa1") > 2, Sheet5.Range("aa1"), 2)
Sheet5.Range("A2:Z" & t3).clear
Sheet2.Range("A3:T" & t4).clear
Interface1
Interface2
comparison
Sheet6.Range("A1:U" & t2).clear
Sheet7.Range("B1:AF" & t1).clear

End Sub
麻烦知道的大虾帮帮忙啊
第八行报错
展开
 我来答
百度网友d5847c21e
2011-09-20 · 超过43用户采纳过TA的回答
知道答主
回答量:100
采纳率:0%
帮助的人:106万
展开全部
Sheet5.Range("A2:C" & t).Copy
第八行你的参数t不合法,
你随便让t=2什么的就不抱错了
你在第八行处设置断点,看看t是什么值
推荐律师服务: 若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询

为你推荐:

下载百度知道APP,抢鲜体验
使用百度知道APP,立即抢鲜体验。你的手机镜头里或许有别人想知道的答案。
扫描二维码下载
×

类别

我们会通过消息、邮箱等方式尽快将举报结果通知您。

说明

0/200

提交
取消

辅 助

模 式