- ©«¤l
- 75
- ¥DÃD
- 1
- ºëµØ
- 0
- ¿n¤À
- 371
- ÂI¦W
- 1
- §@·~¨t²Î
- win7
- ³nÅ骩¥»
- office 2007
- ¾\ŪÅv
- 20
- µù¥U®É¶¡
- 2010-5-4
- ³Ì«áµn¿ý
- 2024-11-23
|
¦^´_ 4# c_c_lai
¦]¬°vba©ñ¦b¼Ò²Õ¬G
Application.OnTime (Now + Sheets("DATA").Range("Y5").Value), "onStarter"
¥B ' Sheets(Sheet1).[A65536].End(xlUp).Offset(1).Resize(, 22) = Sheets("DATA").[A2:V22].Value ´«¦¨
Sheets("Sheet1").Range("A" & Rows.Count).End(xlUp).Offset(1).Resize(1, 22) = Sheets("DATA").[A2:v2].Value
2007 ¥i°õ¦æ
' DDE ¸ê®Æ¬ö¿ý°ÝÃD
Option Explicit
Dim actEnabled As Boolean
Dim cIndex As Single
Private Sub Workbook_Open()
' ¥H¤U¥|¦C¸ê®Æ¤§³]©w¡A¥i°t¦X¹ê§@¡B©Î´ú¸Õ¤§¥Øªº¡Aª½±µ¦b "sheet1" «ü©w¤§³]©wÄæ¡A±oÀH®É¤©¥H²§°Ê¡C
If (Sheets("DATA").Range("X5").Value = "") Then Sheets("DATA").Range("X5").Value = "08:30:00" ' °²³]C6Äæ¦ì¬°ªÅ¥Õ¡A«h¼g¤J¶}½L°_©l®É¶¡
If (Sheets("DATA").Range("X6").Value = "") Then Sheets("DATA").Range("X6").Value = "13:50:00" ' D6Äæ¦ì¥ç¦P¡C(¦¹¨âÄæ¬ö¿ý°_©l²×¤î®É¶¡)
If (Sheets("DATA").Range("Y5").Value = "") Then Sheets("DATA").Range("Y5").Value = "00:05:00" ' ¬ö¿ý¸ê®Æ¶×¤J¬Û¹j®É¶¡¡A¦p¨C¹j¤@¤ÀÄÁ¼g¤J¤@¦¸¡C
If (Sheets("DATA").Range("Y6").Value = "") Then Sheets("DATA").Range("Y6").Value = 2 ' ¬ö¿ý¤w¶×¤J¸ê®Æ¦C¼Æ¡C
If (TimeValue(Now) > Sheets("DATA").Range("X6").Value) Then ' ¦pªG¥Ø«e®É¶¡·~¤w¶W¹L D6 ªºÀç·~®É¬q¡A«h©I¥s.......
Call stopProcedure
Else ' ¤Ï¤§¦b D6 ³]©w®É¶¡¥H«e¡A«h©I¥s.......
Call startProcedure
End If
End Sub
Private Sub Workbook_BeforeClose(Cancel As Boolean)
On Error Resume Next
Call actStop
End Sub
Sub startProcedure() ' «O¯d§@¬°±±¨î¶µ¤§À³¥Îµ{§Ç¡A¦p«ö¶s¤§¥¨¶°À³¥Îµ¥¡C
Call actStart
End Sub
Sub stopProcedure() ' «O¯d§@¬°±±¨î¶µ¤§À³¥Îµ{§Ç¡A¦p«ö¶s¤§¥¨¶°À³¥Îµ¥¡C
Call actStop
End Sub
Sub newTitle()
Sheets(Sheet1).[A1].Resize(, 22) = Sheets(DATA).[A1:V1].Value ' ®M¤W§A±ý¶×¤J¸ê®ÆªºªíÀY¦WºÙ
End Sub
Sub Starter()
If (actEnabled = True And TimeValue(Now) >= Sheets("DATA").Range("X5").Value And TimeValue(Now) <= Sheets("DATA").Range("X6").Value) Then
cIndex = Sheets("DATA").Range("Y6").Value
If (cIndex = 0) Then Call newTitle ' newTitle µ{§Ç (¥Ñ¨Ï¥ÎªÌ¦Û¦æ©w¸q) ¬O±N²Ä¤@¦Cªº¸ê®Æ©ïÀY¦WºÙ¼g¤J¨ìsheet2¡F¦p¤é´Á¡B®É¶¡ªº¹ïÀ³Äæ¦ì¸ê®Æµ¥¡C
Sheets("DATA").Range("X6").Value = cIndex + 1 ' ¬ö¿ý¦C¸¹¥[¤@¡C
' ½Æ»s±q¨é°ÓDDE¶×¤J¤§¬Û¹ïÀ³¦ì¸m¸ê®Æ¡A¦p A1¡BB1¡BC1¡BD1 ¹ïÀ³ªº¥i¯à¬O¤º½L¡B¥~½L¡B¦¨¥æ¡Bº¦¶^µ¥µ¥¡A¥H¦¹Ãþ±À¡C
' Sheets(Sheet1).[A65536].End(xlUp).Offset(1).Resize(, 22) = Sheets("DATA").[A2:V22].Value
Sheets("Sheet1").Range("A" & Rows.Count).End(xlUp).Offset(1).Resize(1, 22) = Sheets("DATA").[A2:v2].Value
cIndex = Sheets("sheet1").Range("X6").Value ' ¤Á°O Counter (p¼Æ¾¹) n¥[¤@¡A§_«h¥Ã»·¬°¹s (·íµM¤w¤]¥i¥H¤£¤©¬ö¿ý¸ê®Æ¦Cz¡A¨ÌÓ¤H²ß©Ê)¡C
End If
End Sub
Sub actStart()
actEnabled = True
Application.OnTime (Now + Sheets("DATA").Range("Y5").Value), "onStarter" ' ¼g¤J¸ê®Æªº±Æµ{ (¥Ø«e¬O¨C¹j¤¤ÀÄÁ¼g¤J¤@¦¸)
End Sub
Sub onStarter()
If Not IsError(Sheets("DATA").[A2]) Then Call Starter
If actEnabled Then Call actStart
End Sub
Sub actStop()
actEnabled = False
On Error Resume Next
Application.OnTime Now, "ThisWorkBook.onStarter", , False
End Sub |
|