Question : MS Excel Macro question: how to save worksheets with worksheet name?

Question: I have a workbook with more than 10 worksheets every month, and would like to write a macro to split it and save individual worksheet with its own sheet name. How can I do that??

Thanks a million!!

Florence

Answer : MS Excel Macro question: how to save worksheets with worksheet name?

Try something as bellow. It works on the active book. I guess you'll need to change the name of the books, currently:
  path = if activebook has a path then same path else current directory.

'--------------------------------------
Sub test()
   Dim Wsh As Worksheet
   Dim path as string

   Application.DisplayAlerts = False
   path= activeworkbook.path
   path = path & iif(right(path,1)=application.pathseparator, "", application.pathseparator)
   On Error Resume Next
   For Each Wsh In ActiveWorkbook.Worksheets
      If Wsh.Visible = xlSheetVisible Then
         Wsh.Copy
         ActiveWorkbook.SaveAs path & "test" & ActiveSheet.Name & ".xls"
         ActiveWorkbook.Close False
      End If
   Next

End Sub
'----------------------------------------

Regards,
Sebastien
Random Solutions  
 
programming4us programming4us