Excel VBA cell.value = Error 400

Josh Hazel
05-06-2008, 09:30 PM
I have a sub routine (for a timer) that enters a Range ("A1").Value = xx and it runs through the loop, counting up or down (depending on another variable). Everything works great, but as soon as I put focus on another cell (i.e., start typing in B1, or F2 in B2) I receive the Error 400 message.

I understand why I am receiving the error, but I need to know how I can get Excel NOT to display the error dialog box, then wait until I get out of whatever cell I happen to be in and continue the timer where it left off.

Any help would be greatly appreciated, I've been running in circles for hours with this problem!!

Thanks

shg
05-06-2008, 09:42 PM
I understand why I am receiving the error,
Don't think I do ...

You have a OnTime macro that decrements the cell, and if you're in edit mode, it throws the error? I'd have thought that the code would not run while Excel is in Edit Mode.

According to MS, Excel can tell, but does not expose to VBA, when Excel is in Edit mode. But perhaps that's irrelevant if that's not what's causing the error ...

Josh Hazel
05-06-2008, 10:43 PM
I think I found a solution in case anyone runs across this problem.

Add a GoTo marker at the beginning of the loop statement.

Using the On Error Resume Next statement at the beginning my sub routine will ignore the Error 400 dialog message box and goto the next step in my sub routine.

The next step in my sub routine uses the following statement:

If Err.Number <> 0 Then
Err.Number = 0
GoTo ResumeFromError
End If

As soon as the user exits out of the active cell, the loop will continue from where it left off.

EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum