lastrow_a = Sheets("庫存").Cells(Rows.Count, 1).End(xlUp).Row
lastrow_b = Sheets("查").Cells(Rows.Count, 1).End(xlUp).Row
For ax = 2 To lastrow_b '查工作表的品號列數
For ay = 3 To 12 Step 3 '核取方塊欄
For ao = 2 To lastrow_a '庫存資料庫
If Sheets("查").Cells(ax, ay) = True And Sheets("查").Cells(ax, 1) = Sheets("庫存").Cells(ao, 1) And Sheets("查").Cells(ax, ay + 1) = Sheets("庫存").Cells(ao, 2) Then
Sheets("庫存").Cells(ao, 4)= Sheets("查").Cells(ax, 2)
end if
next
next
next作者: starry1314 時間: 2015-8-12 17:57
Sub zz()
a = Sheets("庫存").[a1].CurrentRegion
b = Sheets("查").[a1].CurrentRegion
For ax = 2 To UBound(b) 'lastrow_b '查工作表的品號列數
For ay = 3 To 12 Step 3 '核取方塊欄
For ao = 2 To UBound(a) 'lastrow_a '庫存資料庫
If b(ax, ay) = True And b(ax, 1) = a(ao, 1) And b(ax, ay + 1) = a(ao, 2) Then
a(ao, 4) = b(ax, 2)
End If
Next
Next
Next
Sheets("庫存").[a1].Resize(UBound(a), UBound(a, 2)) = a
End Sub作者: dnadark 時間: 2015-8-13 11:40