- One can't copy contents from a hidden worksheet. The worksheet must be visible in order for it to be copied.
- After making it visible, and copying it, there were problems making it hidden again as the current active workbook is the new one instead of the original one.
So the solution is to
1) Make the hidden worksheet visible
2) Activate the original workbook
3) Hide the worksheet
4) Activate the new workbook with the copied sheet
Below's the code, hopefully can help someone who's facing the same problem out there.
Sub copyHidden()'Make hidden sheet visible for copying to new workbookSheets("hiddenSheet").Visible = TrueSheets("hiddenSheet").Copy
'activate the original workbook to hide the sheet againnewbook = Workbooks.CountWorkbooks.Item(newbook - 1).ActivateWorksheets("hiddenSheet").Visible = False
'activate the new workbook with the copied sheetWorkbooks(newbook).ActivateActiveSheet.Name = "copiedSheet"
'the rest of your code here
End Sub
No comments:
Post a Comment