作者kk04014 (阿助)
看板Visual_Basic
标题[VBA ] 比对名称及日期
时间Sat Sep 24 13:55:21 2016
请各位帮忙
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
--
※ 发信站: 批踢踢实业坊(ptt.cc), 来自: 220.134.100.206
※ 文章网址: https://webptt.com/cn.aspx?n=bbs/Visual_Basic/M.1474696523.A.8CE.html
1F:→ MOONRAKER: 请洽code_job 09/24 21:34