Private Sub Worksheet_Change(ByVal Target As Range)
' 當 D2 欄位有異動時, 則去呼叫 RecordPrice 的方法 (Method)。
If Target.Address = "$D$2" Or Target.Address = "$H$2" Or Target.Address = "$L$2" Or Target.Address = "$P$2" Or _
Target.Address = "$T$2" Or Target.Address = "$X$2" Or Target.Address = "$AB$2" Or _
Target.Address = "$AF$2" Or Target.Address = "$AJ$2" Or Target.Address = "$AN$2" Then
Call RecordPrice(Target.Address)
End If
End Sub
回復 72#c_c_lai
Worksheet_Calculate() 是無法判斷哪個儲存格觸發的.
39 帖 的Private Sub Workbook_Open()
中有.Names.Add xRng_Name, xRng ''名稱定義:所有總量的Dee公式的儲存格
當Worksheet_Calculate重算事件執行時
For Each E In Me.Names 去判斷總量有變動,則記錄下來.
Sub 時間()
Sheets("RTD").Cells(2, 1) = WorksheetFunction.Text(Now(), "hh:mm:ss")-------------這個地方時間不用寫入
Application.OnTime Now() + TimeValue("00:00:01"), "時間"
End Sub
---------------------------------------------------------------------------------------------------------------------------
Sub RecordPrice(TG As Range)
Dim WR As Long, cts As Long
With Sheets("RTD")
If .Range("A1") < 1 Then Exit Sub