请各位帮忙
WORBOOK (marketvalue) WORKBOOK fin
name date Tcap DATE TcapA Date TcapB
A 1/1 10 1/1 2/1
A 1/2 11 1/2 2/2
B 2/1 100
B 2/2 101
想先从marketvalue中找到和fin中相同的name,接着把相同日期的Tcap从 marketvalue
复制到fin中的 TcapA 和TcapB中,请问该怎么修改? 谢谢
Sub mv()
Dim i, j As Long
Dim dd, ee As Date
Set bbb = Workbooks("marketvalue.xlsx").Sheets("Data")
Set aaa = Workbooks("fin.xlsm").Sheets("工作表2")
For i = 1 To 1300
For j = 1 To 822743
tt = bbb.Cells(j, 1).Value
bb = aaa.Cells(1, i).Value
dd = bbb.Cells(j, 2).Value
ee = aaa.Cells(i, 1).Value
If IsError(Application.Match(tt, bb, 0)) Then 'NAME相同'
Else
If dd - ee = 0 Then bbb.Cells(j, 3).Copy _
Destination:=aaa.Cells(i, 2)
End If
Next j
Next i
End Sub