ªð¦^¦Cªí ¤W¤@¥DÃD µo©«

[µo°Ý] ¦h±ø¥ó¿z¿ï&ListBox

¦^´_ 81# starbox520
°Ñ¦Ò¬Ý¬Ý:
  1. Sub Test()
  2.     Dim v
  3.     v = GetMyData("SYNAPTICS", "BGA", "17.3X7", 36)
  4.     Stop
  5. End Sub
½Æ»s¥N½X
·s¼W¼Ò²Õ
  1. Private arMaterial, arSh2
  2. Private dResult As Object

  3. Function GetMyData(cus, pkg, size, lc)
  4.     ReadFromSheet
  5.    
  6.     Method1 cus, pkg, size, lc
  7.     Method2 cus, pkg, size, lc
  8.    
  9.     Dim ar
  10.     If dResult.Count > 0 Then
  11.         ar = Application.Transpose(Application.Transpose(dResult.items))
  12.     End If
  13.     GetMyData = ar
  14.    
  15.     Erase arMaterial
  16.     Erase arSh2
  17.     Set dResult = Nothing
  18. End Function

  19. Sub ReadFromSheet()
  20.     Set dResult = CreateObject("scripting.dictionary")
  21.     'Ū¨ì array ¤¤
  22.     With Sheets("¤u§@ªí2")
  23.         arSh2 = .[a1].CurrentRegion.Value
  24.     End With
  25.     With Sheets("§÷®Æ")
  26.         arMaterial = .[a1].CurrentRegion.Value
  27.     End With
  28.    
  29.     '«Ø¥ß²½X¹ïÀ³¥þ¦Wªº¦r¨å
  30.     Dim ar, dCustCode As Object
  31.     Set dCustCode = CreateObject("scripting.dictionary")
  32.     With Sheets("Cus²½X")
  33.         ar = .[a1].CurrentRegion.Value
  34.     End With
  35.     For i = 2 To UBound(ar): dCustCode(ar(i, 1)) = ar(i, 2): Next
  36.    
  37.     ' ±N arMaterial ¤¤¨ú¥N ²½X¬°¥þ¦W
  38.     For i = 2 To UBound(arMaterial)
  39.         If dCustCode.exists(arMaterial(i, 13)) Then
  40.             arMaterial(i, 13) = dCustCode(arMaterial(i, 13))
  41.         End If
  42.     Next
  43. End Sub

  44. Function Method1(cus, pkg, size, lc)
  45.     '§ä¥X match ªºCARRIER1 P/N
  46.     Dim dPN As Object: Set dPN = CreateObject("scripting.dictionary")
  47.     For i = 2 To UBound(arMaterial)
  48.         'M¡BP¡BQ¡BR ¡A find BA
  49.         If StrComp(cus, arMaterial(i, 13), vbTextCompare) = 0 And _
  50.             StrComp(pkg, arMaterial(i, 16), vbTextCompare) = 0 And _
  51.             StrComp(size, arMaterial(i, 17), vbTextCompare) = 0 And _
  52.             StrComp(lc, arMaterial(i, 18), vbTextCompare) = 0 Then
  53.             dPN(arMaterial(i, 53)) = 0
  54.         End If
  55.     Next
  56.    
  57.     Dim ar, key
  58.     For i = 2 To UBound(arMaterial)
  59.         If dPN.exists(arMaterial(i, 53)) Then
  60.             For j = 2 To UBound(arSh2)
  61.                 'M¡BP¡BQ¡BR <-> A¡BB¡BC¡BD
  62.                 If StrComp(arMaterial(i, 13), arSh2(j, 1), vbTextCompare) = 0 And _
  63.                     StrComp(arMaterial(i, 16), arSh2(j, 2), vbTextCompare) = 0 And _
  64.                     StrComp(arMaterial(i, 17), arSh2(j, 3), vbTextCompare) = 0 And _
  65.                     StrComp(arMaterial(i, 18), arSh2(j, 4), vbTextCompare) = 0 Then
  66.                     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")
  67.                 End If
  68.             Next
  69.         End If
  70.     Next
  71. End Function
  72. Function Method2(cus, pkg, size, lc)
  73.     '§ä¥X match ªº Width
  74.     Dim dPN As Object: Set dPN = CreateObject("scripting.dictionary")
  75.     For i = 2 To UBound(arMaterial)
  76.         'M¡BP¡BQ¡BR ¡A find AZ
  77.         If StrComp(cus, arMaterial(i, 13), vbTextCompare) = 0 And _
  78.             StrComp(pkg, arMaterial(i, 16), vbTextCompare) = 0 And _
  79.             StrComp(size, arMaterial(i, 17), vbTextCompare) = 0 And _
  80.             StrComp(lc, arMaterial(i, 18), vbTextCompare) = 0 Then
  81.             dPN(arMaterial(i, 52)) = 0
  82.         End If
  83.     Next
  84.    
  85.     Dim ar, key
  86.     For i = 2 To UBound(arMaterial)
  87.         If dPN.exists(arMaterial(i, 52)) Then
  88.             For j = 2 To UBound(arSh2)
  89.                 'M¡BP¡BQ¡BR <-> A¡BB¡BC¡BD
  90.                 If StrComp(arMaterial(i, 13), arSh2(j, 1), vbTextCompare) = 0 And _
  91.                     StrComp(arMaterial(i, 16), arSh2(j, 2), vbTextCompare) = 0 And _
  92.                     StrComp(arMaterial(i, 17), arSh2(j, 3), vbTextCompare) = 0 And _
  93.                     StrComp(arMaterial(i, 18), arSh2(j, 4), vbTextCompare) = 0 Then
  94.                     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")
  95.                 End If
  96.             Next
  97.         End If
  98.     Next
  99. End Function
½Æ»s¥N½X
ªí¹F¤£²M¡BÃD·N¤£©ú½T¡B¨SªþÀɮ׮榡¡B¨S¦³°Q½×°ÝÃDªººA«×~~~~~~¥H¤W·R²ö¯à§U¡C

TOP

        ÀR«ä¦Û¦b : ª¾ÃÑ­n¥Î¤ßÅé·|¡A¤~¯àÅܦ¨¦Û¤vªº´¼¼z¡C
ªð¦^¦Cªí ¤W¤@¥DÃD