我正在尝试编写一个可以打开两本Excel书籍的程序 - 在第一本书中搜索某些数据并将其插入某个地方的另一本书中。
在一行
.r.Offset(, -27).Copy
发生错误
运行时错误'438'对象不支持此属性或方法。
代码:
Sub грандэ()
Dim book1 As Workbook
Dim book2 As Workbook
Dim r As Range
Dim A As Long
Dim B As Long
Set book1 = Workbooks.Open("E:\Super M\Проект ставки\Поиск решения\Усов 7\Условия для андердогов\таблица.xlsm")
Set book2 = Workbooks.Open("E:\Super M\Проект ставки\Поиск решения\Усов 7\Условия для андердогов\1.xlsm")
A = 29
B = 10
With book1.Worksheets("таблица")
For Each r In .Range("AC34:AC60").Rows
If r.Value = 4 Or r.Value = 6 Then
A = A + 1
If A = 34 Then
B = B + 1
A = 30
End If
.r.Offset(, -27).Copy
book2.Worksheets("Лист1").Cells(A, B).PasteSpecial xlPasteAll
End If
Next r
End With
End Sub