请帮帮我,以下程序给出错误对象不支持此属性或方法
我正在尝试从一个工作簿中复制数据并将其粘贴到另一个工作簿中,但我尝试了所有知识并最终没有结果。
Private Sub cmbsendmail_Click()
'Application.Visible = False
'ThisWorkbook.Save
'Dim copyd As String
Dim mydata As String
Dim mypath As String
Dim tfile As String
Dim wbkwo1 As Workbook
Dim wbkwo2 As Workbook
Dim bname As String
Dim Tdate As Date
Workbooks.Open Filename:="C:\Users\Admin\Desktop\Work\Automated.xlsx"
'data location & range to copy
bname = "Nagarjun B"
Range("A5").Formula = "=Today()-1"
Tdate = Range("A5").Value
Range("6:6").Select
Selection.AutoFilter
Range("A6").AutoFilter Field:=2, Operator:= _
xlFilterValues, Criteria1:="Nagarjun B", visibledropdown:=False
Cells.Find(What:=Tdate, LookIn:=xlFormulas, _
LookAt:=xlPart, SearchOrder:=xlByRows, SearchDirection:=xlNext, _
MatchCase:=False, SearchFormat:=False).Activate
ActiveCell.Offset(0, 1).Select
ActiveCell.Offset(0, 1).Select
ActiveCell.Paste
Application.CutCopyMode = False
ThisWorkbook.Save
wbkwo1.Close
Range("C10:AH10").ClearContents
Unload UserForm2
Unload UserForm1
End Sub
提前谢谢你 Nagarjun B
答案 0 :(得分:0)
看起来错误可能在AutoFilter
行中。
Range("A6").AutoFilter Field:=2, Operator:= _
xlFilterValues, Criteria1:="Nagarjun B", visibledropdown:=False
Cells.Find(What:=Tdate, LookIn:=xlFormulas, _
LookAt:=xlPart, SearchOrder:=xlByRows, SearchDirection:=xlNext, _
MatchCase:=False, SearchFormat:=False).Activate
第一个问题是没有, _
告诉VBA在visibledropdwn:=False
之后继续该行。
第二个问题是,您需要将Criteria2:=
放在Cells.Find...
前面,告诉VBA使用Cells.Find
方法作为Criteria2
参数。