ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Copying and Renaming New Sheet (https://www.excelbanter.com/excel-programming/401096-copying-renaming-new-sheet.html)

T. Jenkins

Copying and Renaming New Sheet
 
Need help in VBA coding to make a copy of a sheet within the same file,
preferably just to the right of the original version, then rename that sheet
to include the day of month. For example, I want to take a sheet named Ship
Plan, make a copy of that sheet, then rename the new sheet Ship Plan (DD),
where DD is the current day of the month.

I know it's not tough, but just haven't done this before, so I'm hoping
someone can help with the code.

Thanks,
Todd


FSt1

Copying and Renaming New Sheet
 
hi
try this...
Sub newsheet()
Dim d As String
d = Format(Now(), "ddd")

ActiveSheet.Cells.Copy
Sheets.Add after:=ActiveSheet
ActiveSheet.Paste
ActiveSheet.Name = "Ship Plan " & d
End Sub

regards
FSt1

"T. Jenkins" wrote:

Need help in VBA coding to make a copy of a sheet within the same file,
preferably just to the right of the original version, then rename that sheet
to include the day of month. For example, I want to take a sheet named Ship
Plan, make a copy of that sheet, then rename the new sheet Ship Plan (DD),
where DD is the current day of the month.

I know it's not tough, but just haven't done this before, so I'm hoping
someone can help with the code.

Thanks,
Todd


JLGWhiz

Copying and Renaming New Sheet
 
Sub newSht()
newDt = Format(Date, "ddd")
Worksheets("Ship Plan").Copy After:=Worksheets("Ship Plan")
ActiveSheet.Name = "Ship Plan_" & newDt
ThisWorkbook.Save
End Sub

"T. Jenkins" wrote:

Need help in VBA coding to make a copy of a sheet within the same file,
preferably just to the right of the original version, then rename that sheet
to include the day of month. For example, I want to take a sheet named Ship
Plan, make a copy of that sheet, then rename the new sheet Ship Plan (DD),
where DD is the current day of the month.

I know it's not tough, but just haven't done this before, so I'm hoping
someone can help with the code.

Thanks,
Todd


JLGWhiz

Copying and Renaming New Sheet
 
I gave you day of the week.
To get day of the month change from:

newDt = Format(Date, "ddd")

TO:

newDt = Format(Date, "dd")


"T. Jenkins" wrote:

Need help in VBA coding to make a copy of a sheet within the same file,
preferably just to the right of the original version, then rename that sheet
to include the day of month. For example, I want to take a sheet named Ship
Plan, make a copy of that sheet, then rename the new sheet Ship Plan (DD),
where DD is the current day of the month.

I know it's not tough, but just haven't done this before, so I'm hoping
someone can help with the code.

Thanks,
Todd


T. Jenkins

Copying and Renaming New Sheet
 
Thanks to both of you for the response. The code by JLG was more of what I
was looking for (i.e., copying the sheet rather than cells). Worked
perfectly.

Thanks for the help.

Todd

"JLGWhiz" wrote:

I gave you day of the week.
To get day of the month change from:

newDt = Format(Date, "ddd")

TO:

newDt = Format(Date, "dd")


"T. Jenkins" wrote:

Need help in VBA coding to make a copy of a sheet within the same file,
preferably just to the right of the original version, then rename that sheet
to include the day of month. For example, I want to take a sheet named Ship
Plan, make a copy of that sheet, then rename the new sheet Ship Plan (DD),
where DD is the current day of the month.

I know it's not tough, but just haven't done this before, so I'm hoping
someone can help with the code.

Thanks,
Todd



All times are GMT +1. The time now is 05:17 AM.

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