- 帖子
- 5923
- 主題
- 13
- 精華
- 1
- 積分
- 5986
- 點名
- 0
- 作業系統
- win10
- 軟體版本
- Office 2010
- 閱讀權限
- 150
- 性別
- 男
- 來自
- 台灣基隆
- 註冊時間
- 2010-5-1
- 最後登錄
- 2022-1-23
        
|
回復 4# faye59 - Option Explicit
- Sub Ex()
- Dim D As Object, i As Integer , xTime As Date
- Set D = CreateObject("Scripting.Dictionary") '字典物件
- With Workbooks.Open("\\Tank\Access\B.xlsx").Sheets("Time").Range("A:A")
- i = 2
- Do While .Cells(i) <> ""
- If Not IsDate(.Cells(i, "B")) Then MsgBox .Cells(i) & " - " & .Cells(i, "B") & " 不是正確時間 ": End
- D(.Cells(i).Text) = Application.Text(.Cells(i, "B"), "HH:MM")
- i = i + 1
- Loop
- End With
- With Sheets("Form").Range("A:A")
- i = 2
- Do While .Cells(i) <> ""
- If D.EXISTS(.Cells(i).Text) Then
- .Cells(i, "E") = D(.Cells(i).Text)
- xTime = Application.Text(.Cells(i, "C") - .Cells(i, "B"), "HH:MM")
- If xTime >= D(.Cells(i).Text) Then
- .Cells(i, "D") = "足夠"
- Else
- .Cells(i, "D") = "不足夠"
- End If
- Else
- .Cells(i, "d") = "沒會員"
- End If
- i = i + 1
- Loop
- End With
- End Sub
複製代碼 |
|