Hello,
I want to copy worksheets from current workbook to a new workbook. The names of Worksheet have format: Name-Month
Ex: Adam-Mar, Adam-Apr, John-Mar, John-Apr.
Now what I am trying to do is copy all Adam sheets to one workbook and all John Worksheets to another.
The code which I currently use only copy one sheet. I don't know how to create an array of all sheets with same name and then copy it. My current code is:
save_name is the name of the person (Adam,John). And Sheets("Cal").Cells(3,4) actually had the value "Mar" and it saved all sheets with Name-Mar with the Loop(Since there was only one sheet per name). But now to copy multiple sheets I need to create an array and I have no idea how to do it. Is it possible to copy all sheets with Adam-* to one workbook.
Any help will be appreciated. Thanks
I want to copy worksheets from current workbook to a new workbook. The names of Worksheet have format: Name-Month
Ex: Adam-Mar, Adam-Apr, John-Mar, John-Apr.
Now what I am trying to do is copy all Adam sheets to one workbook and all John Worksheets to another.
The code which I currently use only copy one sheet. I don't know how to create an array of all sheets with same name and then copy it. My current code is:
Code:
Do While Not IsEmpty(Cells(i, 1))
save_name = Cells(i, 1)
sname = Cells(i, 1) & "-" & Sheets("Cal").Cells(3, 4)
Sheets(sname).Copy
'saving the file code
save_name is the name of the person (Adam,John). And Sheets("Cal").Cells(3,4) actually had the value "Mar" and it saved all sheets with Name-Mar with the Loop(Since there was only one sheet per name). But now to copy multiple sheets I need to create an array and I have no idea how to do it. Is it possible to copy all sheets with Adam-* to one workbook.
Any help will be appreciated. Thanks