CopyPaste 中的应用程序定义或对象定义错误
Application Defined or Object Defined Error in CopyPaste
由于某种原因,我遇到了一个错误,但我找不到原因。它发生在 copy/paste 上,但我不明白它是如何引起的。请帮助
Sub CopyMain()
RowCountBack = 2
Dim n As Integer
RowCount = RowCount / 2
RowCountConst = RowCount
RowCount = RowCount + 1
For n = 1 To 100
'If Cells(RowCount, 10).Value = "AR_Mag (ppm)" Then
If InStr(1, Worksheets("RAW").Cells(RowCount, 7).Value, "AR_Mag", vbTextCompare) > 0 Then
'Sheets("RAW").Range(Cells(RowCountBack, 1), Cells(RowCount, 10)).Copy
WkSht.Range(Cells(RowCountBack, 1), Cells(RowCount, 10)).Copy Destination:= _
Worksheets("AR_MAG").Range("a5") _
.End(xlDown).Offset(2, 0)
RowCount = RowCount + RowCountConst
RowCountBack = RowCountBack + RowCountConst
End If
这是经过多次编辑后的代码。原文在这里有类似的错误
If InStr(1, Worksheets("RAW").Cells(RowCount, 7).Value, "AR_Rot", vbTextCompare) > 0 Then
wkb.Sheets("AR_ROT").Range(Cells(RowCountBack, 1), Cells(RowCount, 10)).Value = wkb.Sheets("RAW").Range(Cells(RowCountBack, 1), Cells(RowCount, 10))
RowCount = RowCount + RowCountConst
RowCountBack = RowCountBack + RowCountConst
End If
如您所见,两个 if 的用途相似
我不知道为什么,但这是工作版本
Range(Cells(RowCountBack, 1), Cells(RowCount, 10)).Copy Destination:=Sheets("AR_MAG").Range("A2")
由于某种原因,我遇到了一个错误,但我找不到原因。它发生在 copy/paste 上,但我不明白它是如何引起的。请帮助
Sub CopyMain()
RowCountBack = 2
Dim n As Integer
RowCount = RowCount / 2
RowCountConst = RowCount
RowCount = RowCount + 1
For n = 1 To 100
'If Cells(RowCount, 10).Value = "AR_Mag (ppm)" Then
If InStr(1, Worksheets("RAW").Cells(RowCount, 7).Value, "AR_Mag", vbTextCompare) > 0 Then
'Sheets("RAW").Range(Cells(RowCountBack, 1), Cells(RowCount, 10)).Copy
WkSht.Range(Cells(RowCountBack, 1), Cells(RowCount, 10)).Copy Destination:= _
Worksheets("AR_MAG").Range("a5") _
.End(xlDown).Offset(2, 0)
RowCount = RowCount + RowCountConst
RowCountBack = RowCountBack + RowCountConst
End If
这是经过多次编辑后的代码。原文在这里有类似的错误
If InStr(1, Worksheets("RAW").Cells(RowCount, 7).Value, "AR_Rot", vbTextCompare) > 0 Then
wkb.Sheets("AR_ROT").Range(Cells(RowCountBack, 1), Cells(RowCount, 10)).Value = wkb.Sheets("RAW").Range(Cells(RowCountBack, 1), Cells(RowCount, 10))
RowCount = RowCount + RowCountConst
RowCountBack = RowCountBack + RowCountConst
End If
如您所见,两个 if 的用途相似
我不知道为什么,但这是工作版本
Range(Cells(RowCountBack, 1), Cells(RowCount, 10)).Copy Destination:=Sheets("AR_MAG").Range("A2")