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

Did you know Excel offers Filter by Selection?
Add the AutoFilter icon to the Quick Access Toolbar. Select a cell containing Apple, click AutoFilter, and you will get all rows with Apple
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,215,268
Messages
6,123,966
Members
449,137
Latest member
yeti1016

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