can we copy the sheetnames too?

  • Thread starter Thread starter Martyn
  • Start date Start date
M

Martyn

Hi,
The below code copies the content of our workbook sheets seperately as new
workbooks, but saves the sheets with default "Sheet1", "Sheet2" name format.
Can we also copy the used sheet names while copying?
TIA
 
Hi,
This is one of the mistakes not "many" people can do....8-)))
I was so tired list night that I forgot to paste it completely. Sorry Frank.
Here goes
=============================
Private Sub Workbook_Open()
' Can we add Application.DisplayAlerts = False here?
Set shOrig = ActiveSheet
For Each sh In ActiveWorkbook.Worksheets
sh.Copy
ActiveWorkbook.SaveAs Filename:="C:\" & sh.Name & ".xls"
ActiveWorkbook.Close
Next sh
shOrig.Activate
End Sub
=============================
Martyn
 
See one reply at your other thread.
Hi,
This is one of the mistakes not "many" people can do....8-)))
I was so tired list night that I forgot to paste it completely. Sorry Frank.
Here goes
=============================
Private Sub Workbook_Open()
' Can we add Application.DisplayAlerts = False here?
Set shOrig = ActiveSheet
For Each sh In ActiveWorkbook.Worksheets
sh.Copy
ActiveWorkbook.SaveAs Filename:="C:\" & sh.Name & ".xls"
ActiveWorkbook.Close
Next sh
shOrig.Activate
End Sub
=============================
Martyn
 
Hi
Dave provided already a solution for this in your other thread
 
Sorry Frank & Dave,
I guess you are right. I think there was a problem with the test
file I was working on. Now I've used the macro on another file and it works
OK!.
Martyn
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top