- 帖子
- 4901
- 主題
- 44
- 精華
- 24
- 積分
- 4916
- 點名
- 142
- 作業系統
- Windows 7
- 軟體版本
- Office 20xx
- 閱讀權限
- 150
- 性別
- 男
- 來自
- 台北
- 註冊時間
- 2010-4-30
- 最後登錄
- 2026-7-16
                
|
本帖最後由 Hsieh 於 2014-2-10 14:56 編輯
回復 4# j88141
課表雛形工作表模組- Private Sub Worksheet_Change(ByVal Target As Range)
- If Target.Count > 1 Then Exit Sub
- Application.EnableEvents = False
- k = Target.Column
- r = Target.Row
- w = Cells(2, k)
- t = IIf(r <= 22, "早上", IIf(r > 22 And r <= 38, "下午", "晚上"))
- If Target<>"" And Check(w & t, Target) > 0 Then MsgBox "該教師此時段不排課": Target.ClearContents
- Application.EnableEvents = True
- End Sub
- Function Check(mystr$, MyVal)
- Dim Ob As Shape, A As Range, Dic As Object
- Set Dic = CreateObject("Scripting.Dictionary")
- With 工作表1
- For Each Ob In .Shapes
- If Ob.OLEFormat.Object.Value = 1 Then
- Set A = Ob.TopLeftCell
- w = .Cells(1, A.Column).MergeArea(1)
- t = .Cells(3, A.Column)
- Dic(w & t) = IIf(Dic(w & t) = "", .Cells(A.Row, 1), Dic(w & t) & "," & .Cells(A.Row, 1))
- End If
- Next
- Check = InStr(Dic(mystr), MyVal)
- End With
- End Function
複製代碼
|
|