|
楼主 |
发表于 2017-2-23 09:39
|
显示全部楼层
Sub 同兴结算平台型号整理()
Dim ws As Worksheet, d As Object, L%, x&, y&, c&, r&
If MsgBox("请确保活动工作表第一行存在“商品名称”关键字。", vbYesNo + vbQuestion + vbDefaultButton1) = vbYes Then
GoTo 100
Else
Exit Sub
End If
100:
On Error GoTo 1000
L = Application.InputBox("请选择商品名称所在的列", "温馨提示", Type:=8).Column
On Error GoTo 0
Application.ScreenUpdating = False
Set d = CreateObject("scripting.dictionary")
With GetObject("C:\Users\Administrator\AppData\Roaming\Microsoft\AddIns" & "\单品名称和型号标准数据表.xlsx")
arr = .Sheets("同兴结算系统型号提取-字典法").[a1].CurrentRegion
.Close False
End With
For x = 2 To UBound(arr)
If Not d.exists(arr(x, 1)) Then
d(arr(x, 1)) = Array(arr(x, 2), arr(x, 3))
End If
Next x
Set ws = ActiveSheet
With ws
c = .Cells(1, .Columns.Count).End(xlToLeft).Column + 1
r = .Cells(Rows.Count, L).End(3).Row
brr = Range(Cells(1, L), Cells(r, L))
For y = 2 To UBound(brr)
If d.exists(brr(y, 1)) Then
sss = d(brr(y, 1))
Cells(y, c).Resize(1, 2) = d(brr(y, 1))
End If
Next y
End With
1000:
Set d = Nothing
Application.ScreenUpdating = True
End Sub
|
|