# Worksheet_Change to Worksheet_Calculate

microsoft-excel-2016vba

I need help re-writing my original code question to a worksheet_calculate. I am new and trying hard to learn but am stuck on this one.

When I use Calculate in place of the change, the code throws numerous errors. I read some comments about adding a sub routine but I can't get it right.

Private Sub Worksheet_Change(ByVal Target As Range)
'Update 20140722
Dim WorkRng As Range
Dim Rng As Range
Dim xOffsetColumn As Integer
xOffsetColumn = -1
If Not WorkRng Is Nothing Then
Application.EnableEvents = False
For Each Rng In WorkRng
If Not VBA.IsEmpty(Rng.Value) Then
Rng.Offset(0, xOffsetColumn).Value = Now
Rng.Offset(0, xOffsetColumn).NumberFormat = "dd-mm-yyyy, hh:mm:ss"
Else
Rng.Offset(0, xOffsetColumn).ClearContents
End If
Next
Application.EnableEvents = True
End If
End Sub