Although I have worked with Excel several years, I am very new to the VBA community. I was hoping that someone might be able to help me in this. I have some code that, when run, goes into an open workbook and copies each sheet to a seperate workbook. I run into problems when I try to save the workbook (created from the worksheet) as it's own file.
What I want to do is to copy each sheet into a new workbook, then save the workbook as the name of the sheet, then close it and go to the next sheet in the original workbook.
When I run the code I get a Run-time error '438' Object doesn't support this property or method.
Help! I can't figure out what i am doing wrong.
Below is the code -
What I want to do is to copy each sheet into a new workbook, then save the workbook as the name of the sheet, then close it and go to the next sheet in the original workbook.
When I run the code I get a Run-time error '438' Object doesn't support this property or method.
Help! I can't figure out what i am doing wrong.
Below is the code -
Code:
Dim Sourcewb As Workbook
Set Sourcewb = ActiveWorkbook
Dim j As Integer, k As Integer
j = Worksheets.Count
For k = 1 To j
With Worksheets(k)
Sheets(k).Select
Application.CutCopyMode = False
Sheets(k).Copy
Dim SaveLocation As String
SaveLocation = "I:\ABT&S\SunGard\Reporting\Advisor Book of Busniess\Division_Reports\Division_Reports_New\"
Dim SaveName As Worksheet
Set SaveName = Sheets(k)
ActiveWorkbook.SaveAs Filename:=SaveLocation & SaveName & ".xlsx", FileFormat:=xlOpenXMLWorkbook, CreateBackup:=False (Where error pops up)
Sourcewb.Activate
End With
Next k
Last edited by a moderator: