View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
Tom Ogilvy Tom Ogilvy is offline
external usenet poster
 
Posts: 27,285
Default rename worksheets after copy

Private Sub Send1_Click()
Dim strDate As String, sName as STring
Sheets(Array("Emp1", "Main")).Copy
strDate = Format(Date, "dd-mm-yy") & " " & Format(Time, "h-mm-ss")
Worksheets("Emp1").Name = "NewData"
ActiveWorkbook.SaveAs "NewEmployeeData.xls"
ActiveWorkbook.SendMail "", _
"Employee Attendance Data"
sname = ActiveWorkbook.Fullname
ActiveWorkbook.Close False
Kill sName
End Sub

--
Regards,
Tom Ogilvy


"Qaspec" wrote in message
...
I want to rename "Emp1" to "NewData". Here is my code.

Private Sub Send1_Click()
Dim strDate As String
Sheets(Array("Emp1", "Main")).Copy
strDate = Format(Date, "dd-mm-yy") & " " & Format(Time, "h-mm-ss")
ActiveWorkbook.SaveAs "NewEmployeeData.xls"
ActiveWorkbook.SendMail "", _
"Employee Attendance Data"
ActiveWorkbook.ChangeFileAccess xlReadOnly
Kill ActiveWorkbook.FullName
ActiveWorkbook.Close False
End Sub