[VBA ] 比对名称及日期

楼主: kk04014 (阿助)   2016-09-24 13:55:21
请各位帮忙
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
作者: MOONRAKER (㊣牛鹤鳗毛人)   2016-09-24 21:34:00
请洽code_job
作者: unfinish (百年孤寂)   2016-10-02 14:24:00
用find 快又简单 https://goo.gl/hka60S

Links booklink

Contact Us: admin [ a t ] ucptt.com