Macro for Selecting Several Worksheets / Ron de Bruin

  • Thread starter Thread starter carl
  • Start date Start date
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"
 
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
 
Back
Top