- 帖子
- 6
- 主題
- 2
- 精華
- 0
- 積分
- 8
- 點名
- 0
- 作業系統
- win10
- 軟體版本
- office2013
- 閱讀權限
- 10
- 註冊時間
- 2016-4-12
- 最後登錄
- 2016-12-23
|
各位大大:
我現在有兩個工作表,我首先需要比對workbook1 和workbook2的 id是否相同,如果id相同再比對日期,日期也一致的話就把workbook 1的值 貼到workbook2 。
Workbook1 workbook2
ID 日期 MV ID 日期 MV
1 2000/1/1 50 1 2000/1/2
1 2000/1/2 52 2 2000/1/6
1 2000/1/3 54 3 2000/1/7
1 2000/1/4 53
2 2000/1/5 60
2 2000/1/6 61
3 2000/1/7 52
Sub marketvalue()
Dim i, j As Integer
Dim tt, cc As Date
Set tbill = Workbooks("mv").Sheets("data")
Set aaa = Workbooks("財務資料").Sheets("sheet2")
For i = 2 To 1048576
For j = 2 To 1148
Let BCODE = tbill.Cells(i, 1)
tt = tbill.Range("B" & i).Value
cc = aaa.Range("A" & j).Value
With aaa.Range("E:E")
Set c = Cells.Find(what:=BCODE, After:=ActiveCell, LookIn:= _
xlFormulas, LookAt:=xlWhole, SearchOrder:=xlByRows, _
SearchDirection:=xlNext, MatchCase:=False).Activate
If Not c Is Nothing Then
With aaa.Range("A:A")
Set dd = Cells.Find(what:=tt, After:=ActiveCell, LookIn:= _
xlFormulas, LookAt:=xlWhole, SearchOrder:=xlByRows, _
SearchDirection:=xlNext, MatchCase:=False).Activate
If Not dd Is Nothing Then
tbill.Cells(i, 5).Copy Destination:=aaa.Cells(j, 15)
End If
End With
End If
End With
Next j
Next i
End Sub
但是這行卻出現沒有設定物件變數或with區塊變數, 請問該怎麼修改?? |
|