jproffer
01-02-2010, 02:39 AM
Sub Auto_Lines()
On Error GoTo 1
Static counter As Long
Static count As Long
Static time As Integer
Static cb1 As Variant
Static cb2 As Variant
Static cb3 As Variant
Static cb4 As Variant
Static cb5 As Variant
Static cb6 As Variant
Static cb7 As Variant
If counter=0 Then
cb1 = UserForm2.CheckBox1.Value
cb2 = UserForm2.CheckBox2.Value
cb3 = UserForm2.CheckBox3.Value
cb4 = UserForm2.CheckBox4.Value
cb5 = UserForm2.CheckBox5.Value
cb6 = UserForm2.CheckBox6.Value
cb7 = UserForm2.CheckBox7.Value
count = UserForm2.TextBox2.Value
time = UserForm2.TextBox1.Value
Unload UserForm2
Goto 3
Else
3
NextTime = Now + (time / 1440) '1440
If cb1 = True Then
Call Pull_NFL_Football_Lines
End If
If cb2 = True Then
Call Pull_NBA_Basketball_Lines
End If
If cb3 = True Then
Call Pull_NCAA_Football_Lines
End If
If cb4 = True Then
Call Pull_NCAA_Basketball_Lines
End If
If cb5 = True Then
Call Pull_NHL_Hockey_Lines
End If
If cb6 = True Then
Call Pull_MLB_Lines
End If
If cb7 = True Then
Call Pull_NFL_Football_Lines
Call Pull_NBA_Basketball_Lines
Call Pull_NCAA_Football_Lines
Call Pull_NCAA_Basketball_Lines
Call Pull_NHL_Hockey_Lines
Call Pull_MLB_Lines
End If
counter = counter + 1
If counter >= count Then
counter = 0
count = 0
time = 0
cb1 = ""
cb2 = ""
cb3 = ""
cb4 = ""
cb5 = ""
cb6 = ""
cb7 = ""
MsgBox "Your Auto-Line session has ended normally.", vbOKOnly, "Auto-Lines Finished"
Exit Sub
Else
Application.OnTime NextTime, "Auto_Lines2"
End If
GoTo 2
1
MsgBox "An error has occured and your" & Chr(13) & "Auto-Line session has ended unexpectedly!", vbCritical, "Auto-Line Error"
2
End Sub
Sub Auto_Lines2()
Call Auto_Lines
End Sub
The above code is called by a command button on a userform. It's supposed to run a third code (or several others...one for each checkbox that is checked) to pull a table(s) online a certain number of times, at a certain interval.
As it is, it does all of that just fine. It gets thru the count at the desired interval, pulling each time, etc...anyhow, it does what it's supposed to....
BUT
When it gets to the end, I get the message that it's done, click ok and then the next time I try to open that userform to run it again, it bugs out "can't find the called object" or something close to that...AND, when I try to save the workbook I get the "crash" message...ya know, "restart, or search for a solution online and restart".
The way I take that is that the userform is not unloading right, and can't be reloaded. When it first did it, I thought it was because the UF was open the whole time (it was in a previous attempt), which is why I have all the static variables holding the UF control values.
Is there anything horribly wrong with the code that you can see?
Any thought are greatly appreciated.
Thanks in advance :)
On Error GoTo 1
Static counter As Long
Static count As Long
Static time As Integer
Static cb1 As Variant
Static cb2 As Variant
Static cb3 As Variant
Static cb4 As Variant
Static cb5 As Variant
Static cb6 As Variant
Static cb7 As Variant
If counter=0 Then
cb1 = UserForm2.CheckBox1.Value
cb2 = UserForm2.CheckBox2.Value
cb3 = UserForm2.CheckBox3.Value
cb4 = UserForm2.CheckBox4.Value
cb5 = UserForm2.CheckBox5.Value
cb6 = UserForm2.CheckBox6.Value
cb7 = UserForm2.CheckBox7.Value
count = UserForm2.TextBox2.Value
time = UserForm2.TextBox1.Value
Unload UserForm2
Goto 3
Else
3
NextTime = Now + (time / 1440) '1440
If cb1 = True Then
Call Pull_NFL_Football_Lines
End If
If cb2 = True Then
Call Pull_NBA_Basketball_Lines
End If
If cb3 = True Then
Call Pull_NCAA_Football_Lines
End If
If cb4 = True Then
Call Pull_NCAA_Basketball_Lines
End If
If cb5 = True Then
Call Pull_NHL_Hockey_Lines
End If
If cb6 = True Then
Call Pull_MLB_Lines
End If
If cb7 = True Then
Call Pull_NFL_Football_Lines
Call Pull_NBA_Basketball_Lines
Call Pull_NCAA_Football_Lines
Call Pull_NCAA_Basketball_Lines
Call Pull_NHL_Hockey_Lines
Call Pull_MLB_Lines
End If
counter = counter + 1
If counter >= count Then
counter = 0
count = 0
time = 0
cb1 = ""
cb2 = ""
cb3 = ""
cb4 = ""
cb5 = ""
cb6 = ""
cb7 = ""
MsgBox "Your Auto-Line session has ended normally.", vbOKOnly, "Auto-Lines Finished"
Exit Sub
Else
Application.OnTime NextTime, "Auto_Lines2"
End If
GoTo 2
1
MsgBox "An error has occured and your" & Chr(13) & "Auto-Line session has ended unexpectedly!", vbCritical, "Auto-Line Error"
2
End Sub
Sub Auto_Lines2()
Call Auto_Lines
End Sub
The above code is called by a command button on a userform. It's supposed to run a third code (or several others...one for each checkbox that is checked) to pull a table(s) online a certain number of times, at a certain interval.
As it is, it does all of that just fine. It gets thru the count at the desired interval, pulling each time, etc...anyhow, it does what it's supposed to....
BUT
When it gets to the end, I get the message that it's done, click ok and then the next time I try to open that userform to run it again, it bugs out "can't find the called object" or something close to that...AND, when I try to save the workbook I get the "crash" message...ya know, "restart, or search for a solution online and restart".
The way I take that is that the userform is not unloading right, and can't be reloaded. When it first did it, I thought it was because the UF was open the whole time (it was in a previous attempt), which is why I have all the static variables holding the UF control values.
Is there anything horribly wrong with the code that you can see?
Any thought are greatly appreciated.
Thanks in advance :)