[VBA ] 關於SUB未定義

作者: pppeeeyyy (pppeeeyyy)   2017-08-17 12:08:54
小弟想請教一下各位大大
Sub time_now()
Sheet1.Range("B23").Value = Time
End Sub
Dim Time1 As Boolean
Sub Schedule()
If Sheet1.Range("B23").Value > Sheet1.Range("B19").Value And
Sheet1.Range("B23").Value < Sheet1.Range("B20").Value Then
Time1 = True
ElseIf Sheet1.Range("B23").Value > Sheet1.Range("B21").Value Or
Sheet1.Range("B23").Value < Sheet1.Range("B22").Value Then
Time1 = True
Else
Time1 = False
End If
Dowhile Time1 = True
DoEvents
If Sheet2.Cells(2, 2) = 1 Then '當這個欄位值為1的時候開始紀錄
Call record '把DDE值抓到EXCEL的副程式
Call timer_Start 'timer開始
End If
Loop
End Sub
Sub timer_Start() '開始timer 每秒call Schedule一次
Application.OnTime Now + TimeValue("00:00:01"), "Schedule", Schedule:=True
End Sub
Sub timer_Stop()
On Error Resume Next '停止timer
Application.OnTime Now + TimeValue("00:00:01"), "Schedule", Schedule:=False
End Sub
Sub record() '紀錄DDE資料的副程式
Sheet2.Cells(2, 2) = Sheet2.Cells(2, 2) + 1 '這欄用來記錄現在行數
Sheet2.Cells(Sheet2.Cells(2, 2), 3) = Sheet1.Range("F11")
Sheet1.Range("B23").Value = Time
'假設DDE要記錄的值在 Sheet1的(1,1)這個欄位
'將這資料存在 Sheet2中
End Sub
我從吹頂版那邊找了一個大大的範例來更改
加了if判別時間還有DOWHILE迴圈想讓他在時間裡面一直重複
但是原本執行是沒問題的只是要一直按執行才會動
可是加了我自己寫的部分就有問題了
還請各位大大們幫我看一下問題出在哪兒?
感謝各位大大
https://i.imgur.com/2bXnGLK.jpg
作者: pppeeeyyy (pppeeeyyy)   2017-08-18 20:30:00
可以了 謝謝大大 原來是少一個空格
作者: fumizuki (矇面加菲獅)   2017-08-17 22:46:00
是哪裡看到有 dowhile 這個單字的 中間缺了一個空格

Links booklink

Contact Us: admin [ a t ] ucptt.com