- 帖子
- 38
- 主題
- 4
- 精華
- 0
- 積分
- 65
- 點名
- 0
- 作業系統
- Window7
- 軟體版本
- office2010
- 閱讀權限
- 20
- 性別
- 男
- 來自
- Taipei
- 註冊時間
- 2011-12-16
- 最後登錄
- 2013-12-13
|
回復 1# adam2010
試試看吧- Private Sub CommandButton1_Click()
- Dim LotID As Range, Tagt As Range, Qty As Range
- Dim a, TalQty
- With sheet2
- For Each LotID In .Range("A2:A" & .[A65536].End(xlUp).Row)
-
- For Each Tagt In .Range("B" & LotID.Row & ":J" & LotID.Row)
-
- If Tagt <> "" Then
-
- With Sheet1
-
- a = Application.Match(LotID, .[A:A], 0)
- aa = Application.CountIf(.[A:A], LotID)
- TalQty = 0
-
- For Each Qty In .Range("D" & a & ":D" & (a + aa - 1))
-
- If Qty.Offset(, 1) <> "" Then GoTo ntxa
-
- Qty = Qty + TalQty
-
- If Qty < Tagt Then
-
- Qty.Offset(, 1) = sheet2.Cells(1, Tagt.Column)
- TalQty = Qty
-
- Else
-
- Qty.Offset(, 1) = sheet2.Cells(1, Tagt.Column)
- GoTo ntla
- End If
- ntxa:
- Next Qty
- ntla:
- End With
- End If
-
- Next Tagt
-
- Next LotID
- End With
-
- End Sub
複製代碼 |
|