I am getting this error when trying to close my file. Not sure how to stop it. My VBA code is below. If I get rid of the macro button and use Ctrl+s instead, there is no problem!!
Thanks for any help with this.....!
VBA Code:
Sub RandyD()
Dim c As Range
Application.ScreenUpdating = False
'Generate Sheet Output "Result", Overwrite Old Sheet
On Error Resume Next
Sheets("Result").Delete
Sheets.Add after:=Sheets(Sheets.Count)
ActiveSheet.Name = "Result"
Sheets("Raw Data").Cells.Copy Range("A1")
On Error GoTo 0
With Sheets("Sheet2") 'Replace Airline With 2 Letters
For Each c In .Range("A2", .Cells(.Rows.Count, "A").End(xlUp))
Range("G:G").Replace What:=c.Value, Replacement:=c.Offset(, 1), LookAt:=xlWhole, SearchOrder:=xlByRows, _
MatchCase:=False, SearchFormat:=False, ReplaceFormat:=False
Next
End With
n = Range("A" & Rows.Count).End(xlUp).Row
h = 4 'data start at row
For i = n To h Step -1
j = WorksheetFunction.CountIf(Range("A" & n & ":A" & h), Cells(i, "A")) 'case insensitive
' Debug.Print Cells(i - j + 1, "A").Resize(j, 11).Address
Cells(i - j + 1, "A").Resize(j, 11).Sort Key1:=Columns(7), Order1:=xlAscending, Header:=xlNo 'Sort By 2 First Letters
If i - j + 1 <> h Then
Rows(i - j + 1).Insert 'Insert Row Between Different Dates
End If
i = i - j + 1
Next
'Combine Code & Flight Number
With Range("B4", Range("B" & Rows.Count).End(xlUp))
.Value = Evaluate(.Columns(6).Address & "&" & .Columns(5).Address)
End With
'Time to Number Format
For Each c In Range("E4", Cells(Rows.Count, "E").End(xlUp))
c = Replace(Left(c.Text, 6), ":", "")
Next
Range("C:D,F:H,J:J").Delete
Range("A3:E3").Value = Array("Date", "Airline", "Time", "PAX", "PCPAX")
Application.ScreenUpdating = True
End Sub
Thanks for any help with this.....!