I'm trying to write an Excel sub to copy all the sheets in a workbook and save them to a specific folder and name them after their tab names. The problem I seem to be having is with saving to a specific folder. The code I have now errors on Set nm = ActiveSheet.Name.
Sub ParseSheets()
Dim ws As Worksheet
Dim nm As Name
Set nm = ActiveSheet.Name
For Each ws In ActiveWorkbook.Worksheets
ws.Copy
'ActiveWorkbook.SaveAs (ActiveSheet.Name)
ActiveWorkbook.SaveAs Filename:= _
"\\domain-01.com\dfs$\care-one\users\care-one_nanthony\desktop\Storage\& nm" _
, FileFormat:=xlNormal, Password:="", WriteResPassword:="", _
ReadOnlyRecommended:=False, CreateBackup:=False
ActiveWorkbook.Close SaveChanges:=True
Next ws
End Sub
Also, you have nm in quotations on the save, and it should not be.
PS - I recommend using MOVE rather than copy. That's because if you have any cross-sheet links, you'll have problems with their linkages (they will link back to the workbook you're copying from and if that's what you want, then its fine).
See article on the subject:
https://www.experts-exchange.com/Software/Office_Productivity/Office_Suites/MS_Office/Excel/A_9730-Workbook-link-problems-after-copying-tabs-to-a-new-workbook.html
Please vote YES if you think its helpful.
My suggested coding, which I just tested successfully:
Open in new window
Dave