MPW
Well-known Member
- Joined
- Oct 7, 2009
- Messages
- 571
- Office Version
- 365
- Platform
- Windows
I have been using this routine to run before the save event. Recently I noticed that it is still running somehow after the fact. I use a hotkey to start a userform, but after I save the workbook I can not use the hotkey until I click stop in the VBA Editor. If I put a breakpoint at the beginning of the BeforeSave routine and click run, the problem does not manifest. let me know if you need more information.
Most of this code was written more than 15 years ago so if it doesn't make sense it was past me's fault!
It calls on some other small routines.
I have included them below
Thanks for the look.
Most of this code was written more than 15 years ago so if it doesn't make sense it was past me's fault!
It calls on some other small routines.
I have included them below
VBA Code:
Public Sub CORE_BeforeSave()
HomeWard
If allline = 0 Then
TotallyAll 'Located in Module 1.
End If
Application.ScreenUpdating = False
MakeWork
Sheets("Script").Unprotect "0000"
Dim oldate
oldate = Sheets("Script").Range("K1")
Application.EnableEvents = False
On Error Resume Next
If Navigator1.CommandButton3.Visible = True Then 'OK Button
If Navigator1.TextBox1.Text <> "" Then
Navigator1.CommandButton3.BackColor = RGB(0, 255, 0)
Navigator1.CommandButton3.Enabled = True
ElseIf Navigator1.TextBox1.Text = "" Then
Navigator1.CommandButton3.BackColor = RGB(192, 192, 192)
Navigator1.CommandButton3.Enabled = False
End If
End If
If IsUserFormLoaded("EditLine") = True Then
Unload EditLine
End If
Sheets("Script").Unprotect "0000"
DoEvents
Sheets("Script").Range("K1") = Now
Navigator1.Label12.Caption = "Saved: " & Format$(Now, "ddd h:mm AM/PM") & " " & Format$(Now, "mm.dd.yy")
Navigator1.Label12.BackColor = RGB(102, 102, 153)
Navigator1.Label12.ForeColor = RGB(255, 255, 204)
Navigator1.CommandButton27.BackColor = RGB(255, 255, 153)
Navigator1.CommandButton28.BackColor = RGB(255, 255, 153)
MakeWork
Sheets("Script").Protect Password:="0000", AllowFormattingCells:=True, AllowFormattingColumns:=True, AllowFormattingRows:=True, AllowFiltering:=True
GoHome
Application.ScreenUpdating = True
End Sub
Sub HomeWard()
'Tracks the active cell location so that it can be returned to it by the gohome routine.
If ActiveCell.Row > 56 Then
OldRow = ActiveCell.Row
OldColumn = ActiveCell.Column
End If
End Sub
Sub TotallyAll()
'Loads all of the ranges needed by the CORE-Script to modify large groups of cells.
allline = Sheets("Script").Cells(Rows.Count, 2).End(xlUp).Row
stA57A = "A57:A" & (allline) & ""
stA57P = "A57:P" & allline & ""
stB57B = "B57:B" & allline & ""
stB57I = "B57:N" & allline & ""
stB57N = "B57:N" & allline & ""
stC57D = "C57:D" & allline & ""
stD57F = "D57:F" & allline & ""
stE57E = "E57:E" & allline & ""
stE56F = "E56:F" & allline & ""
stF57F = "F57:F" & allline & ""
stG56G = "G56:G" & allline & ""
stG57G = "G57:G" & allline & ""
stG57H = "G57:H" & allline & ""
stH57H = "H57:H" & allline & ""
stI57I = "I57:I" & allline & ""
stI57ILong = "I57:I" & (allline + 1) & ""
stI58I = "I58:I" & allline & ""
stJ56J = "J56:J" & allline & ""
stJ57J = "J57:J" & allline & ""
stK57K = "K57:K" & allline & ""
stK57N = "K57:N" & allline & ""
stK57L = "K57:L" & allline & ""
stL57L = "L57:L" & allline & ""
stM57M = "M57:M" & allline & ""
stM57N = "M57:N" & allline & ""
stN57N = "N57:N" & allline & ""
stP57P = "P57:P" & allline & ""
stP57S = "P57:T" & allline & ""
stQ57Q = "Q57:Q" & allline & ""
stQ57R = "Q57:R" & allline & ""
stQ57T = "Q57:T" & allline & ""
stR57R = "R57:R" & allline & ""
stS57S = "S57:S" & allline & ""
stT57T = "T57:T" & allline & ""
stAA56AC = "AA56:AC" & allline & ""
stmul1 = "A57:C" & allline & ",G57:H" & allline & ",J57:J" & allline & ",O57:P" & allline & ""
stmul2 = "D4:D29" & ",K57:N" & allline & ""
End Sub
Sub MakeWork()
Application.EnableEvents = True
Application.Calculation = xlCalculationAutomatic
End Sub
Sub GoHome()
If OldRow <> "" And OldColumn <> "" Then Cells(OldRow, OldColumn).Select
End Sub