Sub New_Copy_Over_Both_Columns()
Dim RunTimer As Date
If BoxOnce = False Then
If MsgBox("WARNING: Auto-Save is Activated and may Save over today's data! Do you want to continue?", 36, "Confirm") = vbNo Then
Exit Sub
Else
MsgBox "Macro is running."
End If
BoxOnce = True
End If
Dim finalTime As Date, currentTime As Date, initialRunTimer As Date
Const hourInterval As Integer = 0, minuteInterval As Integer = 0, secondInterval As Integer = 10
initialRunTimer = Date + TimeSerial(20, 24, 0)
RunTimer = initialRunTimer
finalTime = Date + TimeSerial(20, 30, 0)
currentTime = Now
Do Until DateDiff("s", RunTimer, finalTime) = 0 Or RunTimer > finalTime
'Directly comparing was allowing an extra loop so datediff in seconds is used
If RunTimer >= currentTime Then
Debug.Print RunTimer
Application.OnTime RunTimer, "New_Copy_Over_Both_Columns", latestTime:=RunTimer , Schedule:=True
'Debug.Print RunTimer
Exit Do
End If
RunTimer = RunTimer + TimeSerial(hourInterval, minuteInterval, secondInterval) ' <<<<<<<======New DateTime to check calculated here
Loop
If currentTime < initialRunTimer Or currentTime >= finalTime Then
Exit Sub
End If
Application.ScreenUpdating = False
'Select X:X and shift to right
Columns("X:X").Insert Shift:=xlToRight, CopyOrigin:=xlFormatFromLeftOrAbove
'Select R:R and copy to X1
Columns("R:R").Copy
With Range("X1")
.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
.Font.Bold = False
End With
'Format Rows (1:1) as Time and (2:2) as Date
With Rows("1:1")
.NumberFormat = "[$-F400]h:mm:ss AM/PM"
.Font.Bold = True
End With
With Rows("2:2")
.NumberFormat = "m/d/yy"
.Font.Bold = True
End With
Application.CutCopyMode = False
Columns("X:X").EntireColumn.AutoFit
Application.ScreenUpdating = True
' ActiveWindow.Panes(3).Activate
Range("A15").Select
'Back Up Save at the end of every loop
With Application
.ScreenUpdating = False
.DisplayAlerts = False
End With
With ActiveWorkbook
.SaveAs "C:\Users\Bret\Desktop\Scans" & "\" & "Scans " & Format(Now, "mm-dd-yy") & " Backed Up Every 5 Minutes 1" & " "
'.Close
End With
With Application
.DisplayAlerts = True
.ScreenUpdating = True
End With
End Sub