- 帖子
- 192
- 主題
- 15
- 精華
- 0
- 積分
- 194
- 點名
- 0
- 作業系統
- windows
- 軟體版本
- office2010
- 閱讀權限
- 20
- 性別
- 女
- 註冊時間
- 2016-9-22
- 最後登錄
- 2020-8-28
 
|
156#
發表於 2016-12-28 17:58
| 只看該作者
回復 22# c_c_lai
沒關係C大其實這只是我自己想知道有沒有這部分可以應用而已XD- Sub WIP()
- Dim r%, i%, Arr As Variant
- Dim rng As Range, reg As New RegExp
-
- With reg ' reg : : RegExp/IRegExp2
- .IgnoreCase = True ' IgnoreCase = True : Boolean
- ' S 欄 (Recipe) 篩 出 LS1T | LS1N | TR | BK | VQ 字串,其餘的不要
- .Pattern = "LS1T|LS1N|TR|BK|VQ" ' Pattern = "LS1T|LS1N|TR|BK|VQ" : String
- End With
-
- With Worksheets("WIP")
- Set rng = .Rows(1)
- Arr = .[A1].CurrentRegion.Value ' Arr : : Variant/Variant(1 to 1249, 1 to 27)
-
- For i = 2 To UBound(Arr) ' UBound(Arr) = 1249 : Long
-
- ' (reg.test(Arr(i, 19)) : Arr(i, 19) = "TR1T0.03" (True) / = "PK1T0" (False)) : Boolean
- If Arr(i, 10) = "G" And Arr(i, 18) = "R" And reg.test(Arr(i, 19)) Then
- ' N 欄 (Trackin time) 的時間,以當前系統時間 + 4HRS
- If IsDate(Arr(i, 16)) Then
- If Arr(i, 16) >= Now And Arr(i, 16) < DateAdd("h", 4, Now) Then ' 當下時間 +4Hrs
- If Len(Arr(i, 21)) > 0 And Right(.Cells(i, 9), 1) <> "急貨" Then
- .Cells(i, 9) = .Cells(i, 9) & "急貨" ' 確認是否為急貨單號
- End If
-
- Set rng = Union(rng, .Rows(i))
- End If
- ' N 欄內空白無資料
- ElseIf Len(Arr(i, 16)) = 0 Then
- ' 如 "U" 欄 (急貨單號),有任何值,在 "I" 欄 (Schedule) 加上 * 號
- If Len(Arr(i, 21)) > 0 And Right(.Cells(i, 9), 2) <> "急貨" Then
- .Cells(i, 9) = .Cells(i, 9) & "急貨" ' 確認是否為急貨單號
- End If
- ' Cells(i, 9) = .Cells(i, 9) & "急貨"
- ' .Cells(i, 9) = Left(.Cells(i, 9), Len(.Cells(i, 9)) - 1) & "急貨" ' 確認是否為急貨單號
- ' End If
-
- Set rng = Union(rng, .Rows(i))
- End If
- End If
- Next
- End With
-
- With Worksheets("Sheet1")
- .[A1].CurrentRegion.ClearContents ' 清除上一次的畫面
- rng.Copy .Range("A1")
- End With
- End Sub
複製代碼 C大我"WIP"的 MA code"O"欄 可以把"TR排機&產出" 的 機台編號"B欄"
"TR排機&產出" B欄下的 號碼 會出現在 WIP"的 MA code"O"欄
可以濾掉嗎~
目前我只學保留的方法XD
先濾掉在做我後面寫的篩"G"跟"R"出來
If Arr(i, 10) = "G" And Arr(i, 18) = "R" And reg.test(Arr(i, 19)) Then |
|