Thomas Kuriakose
Active Member
Respected Sirs,
We have multiple sheets with data. The summary sheet should have a button, which on activation should give a list of sheets to be copied to a new workbook with a new filename. The option should be to select one sheet for copy or multiple sheets for copy.
I found this code and this is copying and creating a new workbook. The only problem is I need to enter the sheet names each time in the code and copy the code to a new button for selecting different sheets.
We have multiple sheets with data. The summary sheet should have a button, which on activation should give a list of sheets to be copied to a new workbook with a new filename. The option should be to select one sheet for copy or multiple sheets for copy.
I found this code and this is copying and creating a new workbook. The only problem is I need to enter the sheet names each time in the code and copy the code to a new button for selecting different sheets.
Code:
ption Explicit
Sub TwoSheetsAndYourOut1()
Dim NewName As String
Dim nm As Name
Dim ws As Worksheet
If MsgBox("Copy specific sheets to a new workbook" & vbCr & _
"New sheets will be pasted as values, named ranges removed" _
, vbYesNo, "NewCopy") = vbNo Then Exit Sub
With Application
.ScreenUpdating = False
On Error GoTo ErrCatcher
Sheets(Array("A Jul", "A Aug")).Copy
On Error GoTo 0
For Each ws In ActiveWorkbook.Worksheets
ws.Cells.Copy
ws.[A1].PasteSpecial Paste:=xlValues
ws.Cells.Hyperlinks.Delete
Application.CutCopyMode = False
Cells(1, 1).Select
ws.Activate
Next ws
Cells(1, 1).Select
For Each nm In ActiveWorkbook.Names
nm.Delete
Next nm
NewName = InputBox("Please Specify the name of your new workbook", "New Copy")
ActiveWorkbook.SaveCopyAs ThisWorkbook.Path & "\" & NewName & ".xlsx"
ActiveWorkbook.Close SaveChanges:=False
.ScreenUpdating = True
End With
Exit Sub
ErrCatcher:
MsgBox "Specified sheets do not exist within this workbook"
End Sub
Kindly help with code to get a selection option for single and multiple sheets in one button click.
Thank you very much,
with regards,
thomas