|
[广告] Excel易用宝 - 提升Excel的操作效率 · Excel / WPS表格插件 ★ 免费下载 ★ ★ 使用帮助★
Sub TEST()
Dim strFileName$, wkb As Workbook, arr, i&, dic As Object, iRow&
Set dic = CreateObject("Scripting.Dictionary")
Application.ScreenUpdating = False
strFileName = ThisWorkbook.Path & "\9.29账单.xlsx"
If strFileName <> ThisWorkbook.Name Then
Set wkb = GetObject(strPath & strFileName)
With wkb.Sheets(2)
arr = .[A1].CurrentRegion
For i = 2 To UBound(arr)
If arr(i, 1) <> "" Then
dic(arr(i, 1)) = arr(i, 2)
End If
Next i
End With
wkb.Close False
End If
iRow = Cells(Rows.Count, 1).End(xlUp).Row
arr = [A1].CurrentRegion.Resize(iRow)
For i = 1 To UBound(arr)
If arr(i, 1) <> "" Then arr(i, 2) = dic(arr(i, 1))
Next i
[A1].Resize(UBound(arr), UBound(arr, 2)) = arr
Set wkb = Nothing
Application.ScreenUpdating = True
Beep
End Sub
|
|