ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   rename worksheets after copy (https://www.excelbanter.com/excel-programming/322220-rename-worksheets-after-copy.html)

Qaspec

rename worksheets after copy
 
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


Tom Ogilvy

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




Ron de Bruin

rename worksheets after copy
 
Hi Qaspec

Use this

Sheets(Array("Emp1", "Main")).Copy
Sheets("Emp1").Name = "NewData"


--
Regards Ron de Bruin
http://www.rondebruin.nl



"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





All times are GMT +1. The time now is 09:50 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com