I am having trouble handling the error when my vba code attempts to set a task.successor or task.predecessor value to a row number that is already associated with task. My code attempts to trap the error but it doesn't seem to help. Code looks like this:

On Error Resume Next
T.Predecessors = ActiveCell.Task.ID
If Err.Number <> 0 Then
msgbox ("Warning: There appears to be a circular dependency between....")
On Error GoTo 0
End If

When ActiveCell.Task.ID is already associated with task T the macro continues execution as expected but then at the very end of the sub all the macro work is undone, like the system executes an undo command as it completes the macro. I happen to have a msgbox at the very end of my sub so I can see behind the msgbox that the macro did work as expected, but then when I click OK to the final msgbox in the sub all the work that I saw disappears, like it was 'undone'.