1
對象不支持此屬性或方法。僅在此代碼中的.Paste部分發生。請幫忙,因爲我很困惑。我試圖儘可能簡化代碼來簡單地選擇單元格,複製單元格,選擇目標和粘貼。缺少的東西在這裏...爲什麼不粘貼?使用變量和偏移單元格引用
Sub AIM36DBOCompare()
Dim n As Integer
n = 2
Dim PasteCount As Integer
Dim Value1 As String
Dim Date1 As String
Dim c As Range
PasteCount = 41
Range("AD2:AD1000").Copy Destination:=Range("S41" & Lastrow)
Do While n <= 1000
If Cells(26, n) <> 0 Then
'--------------------------------------------
With Worksheets(1).Range("b2:b10000")
Set c = .Find(Cells(n, 26), LookIn:=xlValues)
If Not c Is Nothing Then
Do
Date1 = c.Offset(0, -1).Address
Value1 = c.Offset(0, 3).Address
If Abs(Cells(n, 25) - Range(Date1).Value) <= 10 Then
Range(Value1).Select
Selection.Copy
Cells(PasteCount, 17).Select
Selection.Paste
PasteCount = PasteCount + 1
Exit Do
End If
Set c = .Find(Cells(n, 26).Value, LookIn:=xlValues)
Loop While Not c Is Nothing
End If
End With
'--------------------------------------------
End If
If Cells(11, n) = 0 Then
Exit Do
End If
n = n + 1
Loop
End Sub
看起來是對的。謝謝。 –