用excel中的新描述更新零件列表
我有两张床单。 每个零件编号约为20k,我需要从Sheet 1 col中获取零件编号。 B,检查它是否存在于Sheet 2 col.A中的任何位置,如果是,则抓取Sheet 2的内容。 B的那一行,然后将其粘贴到具有公式的单元格中。 零件号码列表不匹配100%,所以我不能简单地sorting和复制/粘贴。
谢谢您的帮助!
考虑下面的例子:
Sub PopulateDescriptions() Dim objList As Object Dim objSrc As Range Dim objDst As Range Dim arrList() As Variant Dim arrDesc() As Variant Dim i As Long Set objList = CreateObject("Scripting.Dictionary") With Sheets("Sheet 2") arrList = Intersect(.UsedRange, .Range("A:B")).Value End With For i = 1 To UBound(arrList, 1) objList(arrList(i, 1)) = arrList(i, 2) Next With Sheets("Sheet 1") Set objSrc = Intersect(.UsedRange.Rows, .Range("A:A")) End With Set objDst = objSrc.Offset(0, 2) ' column C arrList = objSrc.Value arrDesc = objDst.Value For i = 1 To UBound(arrList, 1) If objList.Exists(arrList(i, 1)) Then arrDesc(i, 1) = objList(arrList(i, 1)) End If Next objDst.Value = arrDesc End Sub