Hi Leith,
Yes - the problem is actually when I try to recreate the folder it gives error 58 (file already exists) and, when I check, the folder does still exist but with the files gone.
Here's the portion of the code with some bits stripped out:
Case "Reports"
' Exit Sub
Dim FormattedDate As String
Dim strDir As String
Dim fs
Dim RepSheet As Object
AIMsheet.Activate 'this is set earlier, as is some of the variables below
FormattedDate = VBA.Strings.Format(Range("EC1").Value, "dd") & " " & VBA.Strings.Format(Range("EC1").Value, "mmm") & " " & VBA.Strings.Format(Range("EC1").Value, "yyyy")
WhichReportForm.Show
If WhichReportForm.SEbutton Then
Call DeleteFolder("S:\Horsforth Centre\Customer Liaison shared area\Paul Maxfield\LCC\LCC Apprenticeships\Pay Reports\SE Pay reports " & FormattedDate)
Set fs = CreateObject("Scripting.FileSystemObject")
fs.CreateFolder ("S:\Horsforth Centre\Customer Liaison shared area\Paul Maxfield\LCC\LCC Apprenticeships\Pay Reports\SE Pay reports " & FormattedDate)
For Each assessor In Range(ASScol & "4:" & ASScol & "6") 'xlLastRow)
strDir = "S:\Horsforth Centre\Customer Liaison shared area\Paul Maxfield\LCC\LCC Apprenticeships\Pay Reports\SE Pay reports " & FormattedDate & "\" & assessor.Value & " - " & FormattedDate & ".xlsx"
If Not FileThere(strDir) And (Range(ASSCONcol & assessor.Row) = "Self-Employed" Or Range(ASSCONcol & assessor.Row) = "Protocol") Then
Application.SheetsInNewWorkbook = 1
Workbooks.Add.SaveAs strDir
Sheets(1).Name = "Payment Breakdown"
Set RepSheet = Workbooks(assessor.Value & " - " & FormattedDate & ".xlsx").Sheets("Payment Breakdown")
'make report
End If
Next assessor
End If
Set RepSheet = Nothing
Set fs = Nothing
End Select
Bookmarks