[VBA ] 比對名稱及日期
請各位幫忙
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://www.ptt.cc/bbs/Visual_Basic/M.1474696523.A.8CE.html
→
09/24 21:34, , 1F
09/24 21:34, 1F
推
10/02 14:24, , 2F
10/02 14:24, 2F
Visual_Basic 近期熱門文章
PTT數位生活區 即時熱門文章