- 帖子
- 254
- 主題
- 6
- 精華
- 0
- 積分
- 310
- 點名
- 0
- 作業系統
- W10
- 軟體版本
- Excel 2016
- 閱讀權限
- 20
- 性別
- 男
- 來自
- 台灣
- 註冊時間
- 2019-6-16
- 最後登錄
- 2024-9-23
|
25#
發表於 2020-7-12 21:00
| 只看該作者
問題解決了 謝謝準提大大的檔案 還有 n7822123大大的 提點
後來想到的方式 是利用 False 跟 True 的 Boolean 變數 然後再把 輪班的顏色次數先存到 儲存格
再延用 就可以了 XD- If Y <= Cells(6, 11) Then
-
- Select Case DateDiff("d", DateValue(d & "/1/1"), Cells(K, 1)) Mod Cells(5, 11) + 1
- Case 1 To Cells(3, 11)
-
- If Cells(1, 10) <> Year(Date) Then sss = True
-
- If yyy <> 0 And yyy <> Cells(3, 11) And sss = True Then
-
- Cells(U + 1, W) = "夜班"
- Cells(U + 1, W).Font.Color = RGB(114, 0, 55)
- Cells(U + 1, W).Interior.Color = RGB(255, 208, 0)
-
- If Cells(U + 1, W) <> "休假" And Cells(U + 1, W) <> "上班" Then yyy = yyy + 1
- Cells(1, 13) = yyy '儲存延伸天數
-
- If yyy = Cells(3, 11) Then
- yyy = 0
- sss = False
- End If
-
- Else
- Cells(U + 1, W) = "上班"
- Cells(U + 1, W).Font.Color = RGB(0, 0, 89)
- Cells(U + 1, W).Interior.Color = RGB(150, 201, 123)
- End If
-
- If Cells(U + 1, W) <> "休假" And Cells(U + 1, W) <> "夜班" Then kkk = kkk + 1
- Cells(1, 12) = kkk '儲存延伸天數
- If kkk = Cells(3, 11) Then kkk = 0
-
- End Select
-
- ElseIf Y <= Cells(6, 11) * 2 Then
-
- Select Case DateDiff("d", DateValue(d & "/1/1"), Cells(K, 1)) Mod Cells(5, 11) + 1
- Case 1 To Cells(3, 11)
-
- If Cells(1, 10) <> Year(Date) Then sss = True
-
- If kkk <> 0 And kkk <> Cells(3, 11) And sss = True Then
-
- Cells(U + 1, W) = "上班"
- Cells(U + 1, W).Font.Color = RGB(0, 0, 89)
- Cells(U + 1, W).Interior.Color = RGB(150, 201, 123)
-
- If Cells(U + 1, W) <> "休假" And Cells(U + 1, W) <> "夜班" Then kkk = kkk + 1
- Cells(1, 12) = kkk '儲存延伸天數
- If kkk = Cells(3, 11) Then
- kkk = 0
- sss = False
- End If
-
- Else
- Cells(U + 1, W) = "夜班"
- Cells(U + 1, W).Font.Color = RGB(114, 0, 55)
- Cells(U + 1, W).Interior.Color = RGB(255, 208, 0)
- End If
-
- If Cells(U + 1, W) <> "休假" And Cells(U + 1, W) <> "上班" Then yyy = yyy + 1
- Cells(1, 13) = yyy '儲存延伸天數
- If yyy = Cells(3, 11) Then yyy = 0
-
- End Select
-
- End If
複製代碼 謝謝大大們的指導 |
|