Public Sub UpdateNBReport()
frmProcessing.Show vbModeless
DoEvents
Application.ScreenUpdating = False
'Initialise variables
Set wbNB = ActiveWorkbook
Set wsNB = wbNB.Worksheets("NBReport")
lngRowNo = wsNB.Range("A4").End(xlDown).Row
strDataAddress = wbNB.Worksheets("Calculations").Range("rDataAddress").Value
'Delete data from the NBreport data table
wsNB.Rows("4:" & lngRowNo).Delete
'Clear data in first row (excluding formulas)
wsNB.Range("A3:AA3").ClearContents
DoEvents
'Open data file
Workbooks.Open (strDataAddress)
Set wbData = ActiveWorkbook
Set wsData = wbData.ActiveSheet
'Delete unrequired rows
wsData.Rows("1:5").Delete
'Identify last row no
lngRowNo = wsData.Range("A1").End(xlDown).Row
DoEvents
'Clear any filters in the data table
wsNB.Range("A3").Select
ActiveSheet.ShowAllData
'Copy the report into the data table
wsData.Range("A1:AA" & lngRowNo).Copy Destination:=wbNB.Worksheets("NBReport").Range("A3")
Application.CutCopyMode = False
wbData.Close savechanges:=False
DoEvents
'Identify accounts with entry date over 24 months old and delete them
wsNB.ListObjects("tNBData").Range.AutoFilter field:=29, Criteria1:=False
lngRowNo = wsNB.Range("A3").End(xlDown).Row
wsNB.Range("$A2:$AA$" & lngRowNo).Offset(1, 0).Select
lngRowCount = Selection.Rows.Count
lngColumnCount = Selection.Columns.Count
Selection.Resize(lngRowCount - 1, lngColumnCount).EntireRow.Delete
wsNB.Range("A3").Select
ActiveSheet.ShowAllData
wsNB.Range("A1").Select
Set wbNB = Nothing
Set wsNB = Nothing
Set wbData = Nothing
Set wsData = Nothing
Application.ScreenUpdating = True
Unload frmProcessing
End Sub