- ©«¤l
- 1018
- ¥DÃD
- 15
- ºëµØ
- 0
- ¿n¤À
- 1058
- ÂI¦W
- 0
- §@·~¨t²Î
- win7 32bit
- ³nÅ骩¥»
- Office 2016 64-bit
- ¾\ŪÅv
- 50
- ©Ê§O
- ¨k
- ¨Ó¦Û
- ®ç¶é
- µù¥U®É¶¡
- 2012-5-9
- ³Ì«áµn¿ý
- 2022-9-28
|
¦^´_ 81# starbox520
°Ñ¦Ò¬Ý¬Ý:- Sub Test()
- Dim v
- v = GetMyData("SYNAPTICS", "BGA", "17.3X7", 36)
- Stop
- End Sub
½Æ»s¥N½X ·s¼W¼Ò²Õ- Private arMaterial, arSh2
- Private dResult As Object
- Function GetMyData(cus, pkg, size, lc)
- ReadFromSheet
-
- Method1 cus, pkg, size, lc
- Method2 cus, pkg, size, lc
-
- Dim ar
- If dResult.Count > 0 Then
- ar = Application.Transpose(Application.Transpose(dResult.items))
- End If
- GetMyData = ar
-
- Erase arMaterial
- Erase arSh2
- Set dResult = Nothing
- End Function
- Sub ReadFromSheet()
- Set dResult = CreateObject("scripting.dictionary")
- 'Ū¨ì array ¤¤
- With Sheets("¤u§@ªí2")
- arSh2 = .[a1].CurrentRegion.Value
- End With
- With Sheets("§÷®Æ")
- arMaterial = .[a1].CurrentRegion.Value
- End With
-
- '«Ø¥ß²½X¹ïÀ³¥þ¦Wªº¦r¨å
- Dim ar, dCustCode As Object
- Set dCustCode = CreateObject("scripting.dictionary")
- With Sheets("Cus²½X")
- ar = .[a1].CurrentRegion.Value
- End With
- For i = 2 To UBound(ar): dCustCode(ar(i, 1)) = ar(i, 2): Next
-
- ' ±N arMaterial ¤¤¨ú¥N ²½X¬°¥þ¦W
- For i = 2 To UBound(arMaterial)
- If dCustCode.exists(arMaterial(i, 13)) Then
- arMaterial(i, 13) = dCustCode(arMaterial(i, 13))
- End If
- Next
- End Sub
- Function Method1(cus, pkg, size, lc)
- '§ä¥X match ªºCARRIER1 P/N
- Dim dPN As Object: Set dPN = CreateObject("scripting.dictionary")
- For i = 2 To UBound(arMaterial)
- 'M¡BP¡BQ¡BR ¡A find BA
- If StrComp(cus, arMaterial(i, 13), vbTextCompare) = 0 And _
- StrComp(pkg, arMaterial(i, 16), vbTextCompare) = 0 And _
- StrComp(size, arMaterial(i, 17), vbTextCompare) = 0 And _
- StrComp(lc, arMaterial(i, 18), vbTextCompare) = 0 Then
- dPN(arMaterial(i, 53)) = 0
- End If
- Next
-
- Dim ar, key
- For i = 2 To UBound(arMaterial)
- If dPN.exists(arMaterial(i, 53)) Then
- For j = 2 To UBound(arSh2)
- 'M¡BP¡BQ¡BR <-> A¡BB¡BC¡BD
- If StrComp(arMaterial(i, 13), arSh2(j, 1), vbTextCompare) = 0 And _
- StrComp(arMaterial(i, 16), arSh2(j, 2), vbTextCompare) = 0 And _
- StrComp(arMaterial(i, 17), arSh2(j, 3), vbTextCompare) = 0 And _
- StrComp(arMaterial(i, 18), arSh2(j, 4), vbTextCompare) = 0 Then
- If Not dResult.exists(j) Then dResult.Add j, Array(arSh2(j, 1), arSh2(j, 2), arSh2(j, 3), arSh2(j, 4), arSh2(j, 5), arSh2(j, 6), arSh2(j, 7), arSh2(j, 8), "1")
- End If
- Next
- End If
- Next
- End Function
- Function Method2(cus, pkg, size, lc)
- '§ä¥X match ªº Width
- Dim dPN As Object: Set dPN = CreateObject("scripting.dictionary")
- For i = 2 To UBound(arMaterial)
- 'M¡BP¡BQ¡BR ¡A find AZ
- If StrComp(cus, arMaterial(i, 13), vbTextCompare) = 0 And _
- StrComp(pkg, arMaterial(i, 16), vbTextCompare) = 0 And _
- StrComp(size, arMaterial(i, 17), vbTextCompare) = 0 And _
- StrComp(lc, arMaterial(i, 18), vbTextCompare) = 0 Then
- dPN(arMaterial(i, 52)) = 0
- End If
- Next
-
- Dim ar, key
- For i = 2 To UBound(arMaterial)
- If dPN.exists(arMaterial(i, 52)) Then
- For j = 2 To UBound(arSh2)
- 'M¡BP¡BQ¡BR <-> A¡BB¡BC¡BD
- If StrComp(arMaterial(i, 13), arSh2(j, 1), vbTextCompare) = 0 And _
- StrComp(arMaterial(i, 16), arSh2(j, 2), vbTextCompare) = 0 And _
- StrComp(arMaterial(i, 17), arSh2(j, 3), vbTextCompare) = 0 And _
- StrComp(arMaterial(i, 18), arSh2(j, 4), vbTextCompare) = 0 Then
- If Not dResult.exists(j) Then dResult.Add j, Array(arSh2(j, 1), arSh2(j, 2), arSh2(j, 3), arSh2(j, 4), arSh2(j, 5), arSh2(j, 6), arSh2(j, 7), arSh2(j, 8), "2")
- End If
- Next
- End If
- Next
- End Function
½Æ»s¥N½X |
|