snasui.com ยินดีต้อนรับ ยินดีต้อนรับสู่กระดานถามตอบ Excel and VBA และอื่น ๆ ที่เป็นมิตรกับทุกท่าน มีไฟล์แนบมหาศาล ช่วยให้ท่านค้นหาและติดตามศึกษาได้โดยง่าย สมาชิกท่านใดที่ยังไม่ได้ระบุ Version ของ Excel ที่ใช้งานจริง สามารถทำตาม Link นี้เพื่อจะได้รับคำตอบที่ตรงกับ Version ของท่านครับ ระบุ Version ของ Excel
Sub Counter()
If Now > Date + TimeValue("10:00:00") Then
Application.OnTime Date + TimeValue("10:00:00"), "Counter", , True
Else
xxx Wait xxx
End If
If Now > Date + TimeValue("17:00:00") Then
Application.OnTime Date + TimeValue("17:00:00"), "Counter", , False
CurrBook.Close
Exit Sub
End If
Application.OnTime Now + TimeValue("00:00:10"), "Counter"
'nTime = Now + TimeValue("00:00:10")
'Application.OnTime nTime, "Counter"
Call Sound
End Sub
Dim xxx As Date
Sub Counter()
If Now < Date + TimeValue("10:00:00") Then
xxx = Date + TimeValue("10:00:00") - Now
End If
If Now > Date + TimeValue("10:00:00") Then
Application.OnTime Date + TimeValue("10:00:00"), "Counter", , True
Else
Application.Wait xxx
End If
'Other code
End Sub
Public Ntime As Date, Nwait As Date
'Public Non As Date, Noff As Date
'Public CurrBook As Workbook, CheckFile As Boolean
Sub Counter()
Dim Non As Date, Noff As Date
Dim CurrBook As Workbook, CheckFile As Boolean
Set CurrBook = ThisWorkbook
Ntime = Now + TimeValue("00:00:01")
Non = Date + TimeValue("08:00:00")
Noff = Date + TimeValue("08:00:10")
If Now < Non Then
Nwait = Non - Now
Application.Wait Now + Nwait
End If
If Now > Noff Then
On Error Resume Next
Application.OnTime Ntime, "Counter", , False
CurrBook.Save
CurrBook.Close
Exit Sub
End If
Call Sound
Call UseSpeech
Call Sort_Level
Call C_Copy
Call Col_Scale
Application.OnTime Ntime, "Counter", , True
End Sub