Report

Worksheets into Workbook [Solved]

Ask a question Game Start Now 135Posts Thursday January 21, 2010Registration date January 7, 2017 Last seen - Last answered on Jan 2, 2017 at 03:15 PM by Game Start Now
Dear All,

I need to copy each worksheet into workbooks and saved in the specific path except 04 worksheets named NMS, MS, Master and Missing. Further, I need to copy the remaining 04 sheets named mentioned above into each workbook created with macro above.
and all worksheets must be protected with the same password.

Kindly help me in this matter ASAP.

Regards,
Game Start Now
See more 
Helpful
+0
moins plus
Hi GSN,

This is what I got for you:
  • The name of the new workbook will be the one of the sheet that is copied to it.
  • The new workbook is saved in the same folder as your starting file.
  • All worksheets that are password protected will remain so.
  • The empty sheet is deleted on code line 16. In English it's called "Sheet1". Don't know if you use an english version, otherwise you need to change the sheets reference.


Here is the code:
Sub RunMe()
Dim ws As Worksheet
Dim shName As String

For Each ws In Worksheets
    If ws.Name <> "NMS" And ws.Name <> "MS" And _
    ws.Name <> "Master" And ws.Name <> "Missing" Then
        ws.Select
        shName = ws.Name
        Workbooks.Add
        
        ThisWorkbook.ActiveSheet.Copy _
        after:=ActiveWorkbook.Sheets(Sheets.Count)
        
        Application.DisplayAlerts = False
        Sheets("Sheet1").Delete
        Application.DisplayAlerts = True
        
        ThisWorkbook.Sheets("NMS").Copy _
        after:=ActiveWorkbook.Sheets(Sheets.Count)
        ThisWorkbook.Sheets("MS").Copy _
        after:=ActiveWorkbook.Sheets(Sheets.Count)
        ThisWorkbook.Sheets("Master").Copy _
        after:=ActiveWorkbook.Sheets(Sheets.Count)
        ThisWorkbook.Sheets("Missing").Copy _
        after:=ActiveWorkbook.Sheets(Sheets.Count)
        
        ActiveWorkbook.SaveAs Filename:=ThisWorkbook.Path _
        & "\" & shName & ".xlsx"
        ActiveWorkbook.Close
    End If
Next ws
End Sub


Best regards,
Trowa
Game Start Now 135Posts Thursday January 21, 2010Registration date January 7, 2017 Last seen - Jan 2, 2017 at 03:15 PM
Thanks Alot :)
Reply
Leave a comment

Member requests are more likely to be responded to.

Members can monitor the statuses of their requests from their account pages.

A CCM membership gives you access to additional options.

Not a member yet?

Sign up now. It takes less than a minute and is completely free!