Can someone help me understand why the line
doesn't seem to be closing the file? I have the same line in 16 other modules, and they are all closing just fine.
VBA Code:
s.Close SaveChanges:=False
VBA Code:
Option Explicit
Sub ImportLMData()
Application.DisplayAlerts = False
Application.ScreenUpdating = False
Dim m As Workbook, s As Workbook
Dim mD As Worksheet, w As Worksheet
Dim fP As String, fN As String, fE As String
Dim i As Integer, WSCount As Integer
Dim rng As Range
Dim mDLR As Long, mNLR As Long, sDLR As Long
Set m = ThisWorkbook
Set mD = m.Sheets("Data")
mDLR = mD.Range("A" & Rows.Count).End(xlUp).Row
fP = "C:\Users\Import Files\"
fN = "LM"
fN = Dir(fP & fN & "*.xlsx")
Set s = Workbooks.Open(fP & fN)
WSCount = s.Worksheets.Count
For Each w In s.Worksheets
If w.Name <> "Notes" Then
If w.Range("A2").Value = "" Then
Exit Sub
Else
sDLR = w.Range("A" & Rows.Count).End(xlUp).Row
mDLR = mD.Range("A" & Rows.Count).End(xlUp).Row
With w.Range("B2:B" & sDLR).Copy
mD.Range("F" & mDLR + 1).PasteSpecial xlPasteValues
End With
With w.Range("D2:D" & sDLR).Copy
mD.Range("I" & mDLR + 1).PasteSpecial xlPasteValues
End With
With w.Range("A2:A" & sDLR).Copy
mD.Range("Q" & mDLR + 1).PasteSpecial xlPasteValues
End With
With w.Range("E2:E" & sDLR).Copy
mD.Range("O" & mDLR + 1).PasteSpecial xlPasteValues
End With
mNLR = mD.Range("F" & Rows.Count).End(xlUp).Row
mD.Range("A" & mDLR + 1 & ":A" & mNLR).Value = "LM"
mD.Range("B" & mDLR + 1 & ":B" & mNLR).Value = "LM"
mD.Range("C" & mDLR + 1 & ":C" & mNLR).Value = "LOB"
With mD.Range("E" & mDLR + 1 & ":E" & mNLR)
.Value = "=TODAY()"
.Value = .Value
End With
With mD.Range("J" & mDLR + 1 & ":J" & mNLR)
.Value = "=IF(RC[-1]="""","""",RC[-1])"
.NumberFormat = "MMM-YY"
.Value = .Value
End With
End If
End If
Next w
s.Close SaveChanges:=False
Application.ScreenUpdating = True
Application.DisplayAlerts = True
End Sub