|
- Sub test()
- With Sheet2
- lscl = .Cells(2, Columns.Count).End(xlToLeft).Column
- lsrw = .Cells(Rows.Count, 1).End(xlUp).Row
- arr = .[a1].Resize(lsrw, lscl)
- End With
- k = Application.Match("进货价", Application.Index(arr, 2), 0)
- Set dic = CreateObject("scripting.dictionary")
- For a = 3 To UBound(arr)
- dic(arr(a, 2)) = arr(a, k)
- Next a
- With Sheets("销售记录")
- lscl = .Cells(3, Columns.Count).End(xlToLeft).Column
- lsrw = .Cells(Rows.Count, "e").End(xlUp).Row
- brr = .[a1].Resize(lsrw, lscl)
- k = Application.Match("进货价", Application.Index(brr, 3), 0)
- For b = 4 To UBound(brr)
- brr(b, k) = dic(brr(b, 5))
- Next b
- .[a1].Resize(UBound(brr), UBound(brr, 2)) = brr
- End With
- Set dic = Nothing
- End Sub
复制代码 |
|