Doug Mutzig
Board Regular
- Joined
- Jan 1, 2019
- Messages
- 57
- Office Version
- 365
- Platform
- Windows
Good afternoon all,
I have a workbook with 20+ worksheets. Some of the worksheet contain information that an end user may want to email to another person. I currently have it so that you can save select worksheets to a new workbook with only the values and formats of the original workbook saved (no links, etc. between workbooks).
What I would like to do is create the ability for the end user to select multiple worksheets and save them all to one new workbook (values and formats only), by clicking a button that lists the pages with a checkbox to select which ones.
Here is the current code I have for the single page save:
I have no idea where to go from here to get a button, selection list, and code to save to a new worksheet. Any help on this would be greatly appreciated!
I have a workbook with 20+ worksheets. Some of the worksheet contain information that an end user may want to email to another person. I currently have it so that you can save select worksheets to a new workbook with only the values and formats of the original workbook saved (no links, etc. between workbooks).
What I would like to do is create the ability for the end user to select multiple worksheets and save them all to one new workbook (values and formats only), by clicking a button that lists the pages with a checkbox to select which ones.
Here is the current code I have for the single page save:
Code:
Sub GlobalSaveValuesOnly()Dim wsCopy As Worksheet, wsPaste As Worksheet
Dim wb As Workbook
Dim y As String, x As String
x = ActiveWorkbook.Path 'current path of workbook - save location for new workbook
y = Range("x2") 'location for workbook filename
GlobalUnprotect
Application.DisplayAlerts = False
'set the sheet you are copying.
Set wsCopy = ThisWorkbook.ActiveSheet
Set wb = Workbooks.Add
Set wsPaste = wb.Sheets(1)
'Copy everything from copy sheet
wsCopy.Cells.Copy
'Paste Values only
wsPaste.Cells.PasteSpecial xlPasteValues
wsPaste.Cells.PasteSpecial xlPasteFormats
Application.CutCopyMode = False
'Save new workbook
wsPaste.Name = "Data" 'Change if needed
wb.SaveAs x & "\" & y & ".xlsx", FileFormat:=xlOpenXMLWorkbook
ActiveWorkbook.Close SaveChanges:=False
MsgBox ("The data has been saved to a new Workbook in the same location as this workbook")
Application.DisplayAlerts = True
GlobalProtect
End Sub
I have no idea where to go from here to get a button, selection list, and code to save to a new worksheet. Any help on this would be greatly appreciated!