|
[广告] Excel易用宝 - 提升Excel的操作效率 · Excel / WPS表格插件 ★ 免费下载 ★ ★ 使用帮助★
Sub TEST()
Dim strFileName$, strPath$, wkb As Workbook
Dim arr, i&, dic As Object
Application.ScreenUpdating = False
Set dic = CreateObject("Scripting.Dictionary")
strPath = ThisWorkbook.Path & "\"
strFileName = Dir(strPath & "客户信息20211128.xlsx")
If strFileName = "" Then MsgBox "读取文件不存在,请检查!": Exit Sub
Set wkb = GetObject(strPath & strFileName)
With wkb.Sheets(1)
arr = .[A1].CurrentRegion
For i = 2 To UBound(arr)
dic(arr(i, 1)) = arr(i, 2)
Next i
End With
wkb.Close False
arr = [A1].CurrentRegion
For i = 2 To UBound(arr)
arr(i, 10) = dic(arr(i, 3))
Next i
[A1].CurrentRegion = arr
Set wkb = Nothing
Set dic = Nothing
Application.ScreenUpdating = True
Beep
End Sub
|
|