rename worksheets after copy

Q

Qaspec

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
 
T

Tom Ogilvy

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
 
R

Ron de Bruin

Hi Qaspec

Use this

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

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