Macro stops after 38 hours, is this a feature?

mrshl9898

Well-known Member
Joined
Feb 6, 2012
Messages
1,951
Hi,

We have an SQL query that uses a stored procedure on our database. For some reason it keeps going into error every few days.

I made the below to refresh the query and try to detect the time for the break, however, coming in this morning to check it, it has errored (msgbox displayed) after 38 hours.

Is there anything built into excel that would cause this?

Thanks in advance

Code:
Public counter As Long
Public counter1 As Long
Public starttime As String


Sub breaktester()


Application.DisplayAlerts = False


If starttime = "" Then
starttime = Now()
End If


If counter = 0 Then
counter = 1
End If


restart:
On Error GoTo getout
ActiveWorkbook.Connections("MainstreetNZ1").Refresh
counter = counter + 1
counter1 = Format(counter, "0,000")
Application.StatusBar = "Attempt no. " & counter1
GoTo restart


getout:
MsgBox "Search started at - " & starttime & vbNewLine & "Search stopped at - " & Now() & vbNewLine & "attempt no. " & counter


Application.DisplayAlerts = True


End Sub

Msgbox was:

Search started at - 23/11/18 15:37:58
Search stopped at - 25/11/188 05:37:57
attempt no. 26809
 
Last edited:

Excel Facts

Format cells as date
Select range and press Ctrl+Shift+3 to format cells as date. (Shift 3 is the # sign which sort of looks like a small calendar).
Is there anything built into excel that would cause this?
No.

It might be helpful to see what the actual error message is. You can add to your error catching with something like:
Code:
MsgBox err.Number & ": " & err.Description

Also note that the Format function actually returns a String value, not a numeric one.
So you should declare counter1 as String, and not Long
Actually, I am not sure what the purpose of counter1 is anyway. You can just display counter. Why the need to format it?
 
Upvote 0

Forum statistics

Threads
1,224,818
Messages
6,181,152
Members
453,021
Latest member
Justyna P

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