Hello,
I have an excel worksheet which calls a function. The function evaluates the arguments passed to it by cell in the spreadsheet, and then, depending on the result, places a timestamp in a cell adjacent to the one that made the call. However, I am getting a #VALUE error. Stepping through, the error occurs when the function attempts to place a value in the adjacent cell. Perhaps this is not something that can be done by a function. Can anyone confirm this? Is there a way to do this with a function? I could do it with a macro but it's a dynamic spreadsheet with other macros running at set intervals. Many thanks!
I have an excel worksheet which calls a function. The function evaluates the arguments passed to it by cell in the spreadsheet, and then, depending on the result, places a timestamp in a cell adjacent to the one that made the call. However, I am getting a #VALUE error. Stepping through, the error occurs when the function attempts to place a value in the adjacent cell. Perhaps this is not something that can be done by a function. Can anyone confirm this? Is there a way to do this with a function? I could do it with a macro but it's a dynamic spreadsheet with other macros running at set intervals. Many thanks!
Code:
Public Function Timestamp(Curr As Integer, Prev As Integer, row As Integer, ptime As Double)
If Curr = 0 And Prev <> 0 Then
If ptime <> 0 Then
If Now - ptime >= (0.5 / 24) Then
Sheets("Signals").Cells(row, 5).Value = Now
Timestamp = 1
End If
Else
Timestamp = 1
Sheets("Signals").Cells(row, 5).Value = Now
End If
Else
Timestamp = 0
End If
End Function