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
麻烦知道的大虾帮帮忙啊
第八行报错 展开
下面是调试代码:
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
麻烦知道的大虾帮帮忙啊
第八行报错 展开
1个回答
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询