回覆列表
  • 1 # 使用者834195712159

    1,首先從原理圖裡匯出BOM,並整理好。

    2,然後開啟excel開發工具,編寫以下程式碼。

    Sub bom處理()

    Dim sh1, sh2 As Worksheet

    Dim LastRow1 As Long

    Dim LastRow2 As Long

    Dim j As Long

    Workbooks.Open Filename:="E:\bomlib\bomlib-20191115.xls"

    Set sh1 = Workbooks(1).Sheets(1)

    Set sh2 = Workbooks(2).Sheets(1)

    LastRow1 = sh1.Range("A65536").End(xlUp).Row

    LastRow2 = sh2.Range("a65536").End(xlUp).Row

    For i = 1 To LastRow1

    For j = 1 To LastRow2

    If sh2.Cells(j, 4) = sh1.Cells(i, 4) Then

    sh1.Cells(i, 2) = sh2.Cells(j, 1)

    sh1.Cells(i, 3) = sh2.Cells(j, 2)

    End If

    Next

    Next

    Workbooks(2).Close

    End Sub

    3,執行程式碼,就能從物料庫裡準確快速地找到物料編碼,並填寫到BOM裡,幾秒鐘的時,非常高效。

  • 中秋節和大豐收的關聯?
  • Could not connect to the server是什麼意思?