Macro for Selecting Several Worksheets / Ron de Bruin

C

carl

Hi. This code worked awesome - as did your other replies
to my questions.

On this piece of the code, is there any way to insert the
currrent date into the filename ? Thanks again.

Nwb.SaveAs "Sheet " & sh.Name & " of " _
& ThisWorkbook.Name & ".xls"
 
R

Ron de Bruin

You can use this

Format(Now, "dd-mm-yy h-mm-ss")

Sub test2()
Dim sh As Worksheet
Dim Nwb As Workbook
Application.ScreenUpdating = False
For Each sh In ActiveWindow.SelectedSheets
sh.Copy
Set Nwb = ActiveWorkbook
Nwb.SaveAs "Sheet " & sh.Name & " of " _
& ThisWorkbook.Name & " " & Format(Now, "dd-mm-yy h-mm-ss") & ".xls"
Nwb.Close False
Next
Application.ScreenUpdating = True
End Sub
 

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

Top