我正在将我的团队发送的每日报告合并到名为“主文件”的单个文件中,它将为我的每个团队成员分别提供每个工作表。我需要找到单元格中包含今天的日期在我的团队成员发送一份报告,并复制相应的细胞,并将其粘贴在“主文件” 下面是代码无法选择包含今天日期的单元
Sub Copy_data()
Sheets("Daily Report").Select
Range("A7").Select
Dim mydate As Date
mydate = Range("B1")
For i = 1 To 4 'this is sample actually i have 38 sheets
Dim filename As Variant
ActiveCell.Offset(1, 0).Select
filename = ActiveCell.Value
Workbooks.Open "C:\Users\test\Desktop\AP\" & filename
Application.Wait (Now + TimeValue("0:00:02"))
Sheets("Dashboard").Select
Cells.Find(What:=mydate, After:=ActiveCell, LookIn:=xlFormulas, _
LookAt:=xlPart, SearchOrder:=xlByRows, SearchDirection:=xlNext, _
MatchCase:=False, SearchFormat:=False).Activate ' this is where i get an error as "object variable or with block variable not set"
ActiveCell.Offset(0, 2).Select
Dim currentcell As Integer
currentcell = ActiveCell.Row
Range(Selection, Cells(currentcell, 10)).Copy
Windows("Agent Performance.xls").Activate
Dim sheetname As String
sheetname = ActiveCell.Offset(0, 1).Value
Sheets(sheetname).Select
'Here again i have to find the cell with today's date and paste the data which i copied
Next i
End Sub
注: - 这是工作的罚款在早期阶段。在对格式和外观进行了少量更改后,还在“主文件”中添加了所有表单,然后我收到此错误!我也是VBA的初学者,请原谅我的缺点。
而不是'xlFormulas'查看一下'xlValues' –
感谢但答复得到同样的错误! – David
什么错误和什么行? –