Worksheet_Calculation to create a Timer

awriter

New Member
Joined
Sep 18, 2006
Messages
12
Let me start off by trying to explain what I am trying to accomplish.
I have a column of data that updates occasionally from a RTD data feed. Each cell in the column updates at different times. I would like a timer to start in the column to the right of data when the data is updated. The timer would reset to 0 when an update occurs and the process would start over.

I'm sure that there is an easier way but this is the convoluted process I chose:

BTW- I am using XP Pro Excel 2003 sp2

Private Sub Worksheet_Change(ByVal Target As Range)
If Target.Column = 5 Then
ThisRow = Target.Row
If Target.Value <> 0 Then
Range("F" & ThisRow) = Now()
Else
Range("F" & ThisRow) = 0
End If
End If

End Sub


Now this just posted the time that the cell change occurred in the column to the right. I then had a cell somewhere in the sheet tracking the current time through =Now() . I would then subtract the time stamped value of the cell change from the cell where the =Now() was and that was great. I had the timer that I wanted.

My problem is that using the RTD updates are considered Calculations not Changes, so it doesn't work!!!
I know that I need to use the Worksheet_Calculation command but I cannot get it to work at all.
I am worried that I will not be able to accomplish this because it sounds like if there was any calculation in the entire sheet ALL the timer would reset to Zero.

If anyone has any idea of how to accomplish this I am all ears. I would assume there is also an easier and more efficient way of doing this just that I cannot figure it out.
Let me finish by saying that my experience with VB is VERY limited.

Thank you in advance,
Adam
 

Excel Facts

Formula for Yesterday
Name Manager, New Name. Yesterday =TODAY()-1. OK. Then, use =YESTERDAY in any cell. Tomorrow could be =TODAY()+1.
Adam,

Try the below addition to your code (it copies the 'F & ThisRow' cell, and does an Edit, Past Special, Values, thereby removing the formula):


Private Sub Worksheet_Change(ByVal Target As Range)
If Target.Column = 5 Then
ThisRow = Target.Row
If Target.Value <> 0 Then
Range("F" & ThisRow) = Now()

Range("F" & ThisRow).Select
Selection.Copy
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
ActiveSheet.Paste
Application.CutCopyMode = False

Else
Range("F" & ThisRow) = 0
End If
End If

End Sub


I am using Windows XP Professional SP2 and Excel 2003 SP2.

Have a great day,
Stan
 
Upvote 0
Stan,
I tried the code and I'm still having the same issue. The problem is that the Target location (where I have the data updating through =RTD() and changes every so offten) is column #5 or "E". When the cell value changes by virtue of the RTD equation column "F" does not record the time of the update because the Worksheet_Change does not work for calculations. It DOES work fine if I manually make a change to any cell in column "E".
So I don't understatand the reasoning for your additional code? But I think I understand what you are trying to do. If I had the =RTD data in column #4 or "D" and if there was a change in the data and I were able to copy it to column "E" using the special paste Value function then it might work.
That leaves one problem I still have no idea of how to use the Worksheet_Calculation function????
I would think if I could accomplish what I want if I could get the Worksheet_Calculation to work and not have to do both (Worksheet_Calculation and then the Worksheet_Change).

Any other ideas,
Adam
 
Upvote 0

Forum statistics

Threads
1,214,911
Messages
6,122,192
Members
449,072
Latest member
DW Draft

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top