I am beside myself! I have this simple code and it keeps giving me the run time error ....cannot access file "C:(various characters)..... on save as. This is so simple I SHOULD be able to correct, but GAH! I have Dimmed S, and outputPath as String.
This is the code:
outputPath = "C:\LLC"
'Create Email Sheets Loop
Set PF = Sheets("PIVOT").PivotTables("EmailsTable").PivotFields("Responsible Party")
Application.DisplayAlerts = False
For Each Pi In PF.PivotItems
Pi.DataRange.ShowDetail = True
ActiveSheet.Name = Pi.Name
ActiveSheet.Copy
With ActiveSheet.ListObjects(1)
Set rList = .Range
.Unlist
End With
ActiveSheet.Range("J2").Select
S = Range("J2").Value
ChDir outputPath
ActiveWorkbook.SaveAs Filename:= _
outputPath & S & ".xlsx" _
, FileFormat:=51, CreateBackup:=False
ActiveWorkbook.Close
ActiveSheet.Delete
Next Pi
Application.DisplayAlerts = True
Thank you for your assistance.
I have tried to name the file as the sheet name, I have created all kinds of different name variables, I'm just frustrated.