运行到11行的时候,提示excel VBA中出现运行时错误"1004“:应用程序定义或对象定义错误
SubAAA()DimIAsLong,JAsLong,KAsInteger,I1AsWorksheet,J1AsWorksheetSetI1=Worksheets("Sh...
Sub AAA()
Dim I As Long, J As Long, K As Integer, I1 As Worksheet, J1 As Worksheet
Set I1 = Worksheets("Sheet1")
Set J1 = Worksheets("Sheet3")
For I = 2 To I1.Range("A65536").End(xlUp).Row
For J = 2 To J1.Range("A65536").End(xlUp).Row
If I1.Cells(I, 1) = J1.Cells(J, 1) And J1.Cells(J, 10) <> "" Then
For K = 10 To 40
J1.Cells(I, K).Copy
I1.Cells(I, K).PasteSpecial Paste:=xlPasteValues
Next
End If
Next
Next
End Sub 展开
Dim I As Long, J As Long, K As Integer, I1 As Worksheet, J1 As Worksheet
Set I1 = Worksheets("Sheet1")
Set J1 = Worksheets("Sheet3")
For I = 2 To I1.Range("A65536").End(xlUp).Row
For J = 2 To J1.Range("A65536").End(xlUp).Row
If I1.Cells(I, 1) = J1.Cells(J, 1) And J1.Cells(J, 10) <> "" Then
For K = 10 To 40
J1.Cells(I, K).Copy
I1.Cells(I, K).PasteSpecial Paste:=xlPasteValues
Next
End If
Next
Next
End Sub 展开
展开全部
应该出现错误的位置在 I1.Cells(I, K).PasteSpecial Paste:=xlPasteValues
在粘贴时候要激活工作表才行 所以在 这一句的上面加一句
l1.activate
在粘贴时候要激活工作表才行 所以在 这一句的上面加一句
l1.activate
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询