TheRobRush
New Member
- Joined
- Nov 5, 2018
- Messages
- 39
I have a couple userforms with very similar code, see below for an example.
The problem with them is occasionally excel freezes as they are opened right before the form is displayed.
Pressing ctrl-alt-del and close excel pops up with a cannot close excel waiting for response/input from you.
If you cancel the closing at this point, then repeat that step one more time after the second cancel the form is loaded and ready to go. VERY strange.
hoping someone can see an error below that would be causing this. Including my public variables page, and the forms initialize data...
Public decl
USERFORM INIT
The problem with them is occasionally excel freezes as they are opened right before the form is displayed.
Pressing ctrl-alt-del and close excel pops up with a cannot close excel waiting for response/input from you.
If you cancel the closing at this point, then repeat that step one more time after the second cancel the form is loaded and ready to go. VERY strange.
hoping someone can see an error below that would be causing this. Including my public variables page, and the forms initialize data...
Public decl
Code:
Option Explicit
Public MillaJovavich As String
Public AnnaKendrick As String
Public NextDayStart As Boolean
Public NextDayEnd As Boolean
USERFORM INIT
Code:
Private Sub Userform_Initialize()
Application.EnableEvents = False
Application.Calculation = xlCalculationManual
Dim hr As Long
Dim hr2 As Long
Dim d As Date
' Dim min As Long
' Dim min2 As Long
Dim TK_min As String
Dim Squirtle, Bulbasaur, Charmander
d = Now()
Application.ScreenUpdating = False
Label6.Caption = "Dispatching: " & ActiveSheet.Range("A" & Selection.row).Value
' & " " & ActiveSheet.Range("F" & Selection.row).Value
hr = Left(Format(Now(), "HH:MM"), 2)
min = Right(Format(Now(), "HH:MM"), 2)
hr2 = Left(Format(Now(), "HH:MM"), 2)
min2 = Right(Format(Now(), "HH:MM"), 2)
'====================== CHECK 24 HOUR ROLLOVER
'==========STEP 1 DONE
MsgBox "CHECKPOINT 1"
'==========STEP 1 DONE
If hr = 23 And min >= 45 Then
NextDayStart = True
Else
NextDayStart = False
End If
'==========STEP 1 DONE
MsgBox "CHECKPOINT 2"
'==========STEP 1 DONE
'=============== CHANGE MILITARY TIME TO NORMAL TIME
If hr = 24 Or hr <= 11 Then
MillaJovavich = "AM"
ElseIf hr >= 13 Then
hr = hr - 12
MillaJovavich = "PM"
ElseIf hr = 12 Then
MillaJovavich = "PM"
End If
'==========STEP 1 DONE
MsgBox "CHECKPOINT 3"
'==========STEP 1 DONE
If hr = 0 Then
hr = 12
ElseIf hr = 24 Then
hr = 12
Else
hr = hr
End If
'==========STEP 1 DONE
MsgBox "CHECKPOINT 4"
'==========STEP 1 DONE
'=============== CONTINUED - END TIME
If hr2 = 24 Or hr2 <= 11 Then
AnnaKendrick = "AM"
ElseIf hr2 >= 13 Then
hr2 = hr2 - 12
AnnaKendrick = "PM"
ElseIf hr2 = 12 Then
AnnaKendrick = "PM"
End If
'==========STEP 1 DONE
MsgBox "CHECKPOINT 5"
'==========STEP 1 DONE
If hr2 = 0 Then
hr2 = 12
ElseIf hr2 = 24 Then
hr2 = 12
Else
hr2 = hr2
End If
'==========STEP 1 DONE
MsgBox "CHECKPOINT 6"
'==========STEP 1 DONE
'=============== END FORMAT CONVERSION
'=============== ADD 0 TO MINUTES TAKEN AWAY
' If min < 10 Then
' min = "0" & min
' End If
'
' If min2 < 10 Then
' min2 = "0" & min2
' End If
'=============== SET SELECTABLE TIMES
Dim call_times_hr As Variant
ReDim call_times_hr(24)
call_times_hr = Array("01", "02", "03", "04", "05", "06", "07", "08", "09", "10", "11", "12", "13", "14", "15", "16", "17", "18", "19", "20", "21", "22", "23", "00")
ComboBox1.ColumnCount = 1
ComboBox3.ColumnCount = 1
ComboBox1.List() = call_times_hr
ComboBox3.List() = call_times_hr
ComboBox1.Value = hr
ComboBox3.Value = hr2
Dim call_times_min As Variant
ReDim call_times_min(10)
call_times_min = Array("00", "06", "12", "18", "24", "30", "36", "42", "48", "54")
ComboBox2.ColumnCount = 1
ComboBox4.ColumnCount = 1
ComboBox2.List() = call_times_min
ComboBox4.List() = call_times_min
'===============
' If min < 10 Then
' min = "0" & min
' End If
'
' If min2 < 10 Then
' min2 = "0" & min2
' End If
'==========STEP 1 DONE
MsgBox "CHECKPOINT 7"
'==========STEP 1 DONE
ComboBox2.Value = min
If min + 15 >= 60 Then
min2 = min + 15 - 60
hr2 = hr2 + 1
ComboBox4.Value = min2
ComboBox3.Value = hr2
Else
ComboBox4.Value = min + 15
End If
' If min2 < 10 Then
' min2 = "0" & min2
' End If
Application.EnableEvents = True
Application.Calculation = xlCalculationAutomatic
End Sub