Duplicate Existing Worksheet and Name Tab

Papi

Well-known Member
Joined
May 22, 2007
Messages
1,592
I am trying to to take a formatted worksheet called Blank which sits on the far left side and copy it to the far right side (next to the last working sheet) and change cell D1 to reflect seven days more than the last sheet i.e. Jul 25 would now becom Aug 1 etc.

Each tab is named the month and day using "mmm d" which is sitting as a formula in Cell H1 named Tab_Name =CONCATENATE(TEXT(D1,"mmm")," ",TEXT(D1,"d")) so would like to have the tab named using that format.

Any help would be greatly appreciated.
 
Now it is giving a VBA Error 400 and the new filename is Blank (2). The date is still fine in the new worksheet but the naming is out.
 
Upvote 0

Excel Facts

Format cells as date
Select range and press Ctrl+Shift+3 to format cells as date. (Shift 3 is the # sign which sort of looks like a small calendar).
Before you run the macro, make sure that D1 of the last sheet contains a date.
 
Upvote 0
Hello Peter,

The last worksheet has July 25 in cell D1 and the Blank worksheet does not have anything in D1. The renaming of D1 works great. The confusion is where it is getting the name for the tab as it is not going to Blank (2). On one of the previous codes it was naming the tab with what was in the Blank cell. What I need is for it to name it from the new worksheet cell D1.
 
Upvote 0
What I need is for it to name it from the new worksheet cell D1.

That is exactly what it does if you read the code. But the date is the date in the previous sheet D1 plus 7. If that isn't a valid date I would expect the code to error.
 
Upvote 0
The date is valid as I tested it by running a quick formula = D1+& and it returns August 1 from July 25. With my limited understanding of such code it appears that your code is correct but for some reason it seems to be naming the file tab with the blank file rather than the new worksheet. That appears true as it is calling the new file Blank (2) as though it is duplicating that first.
 
Upvote 0
I see where I may be going wrong as your file is perfect. I may have not entered your code in the correct area as I see yours shows Option Explicit and mine does not. What am I doing wrong?
 
Upvote 0
I entered mine by right clicking the tab and going view code and pasting it there.
 
Upvote 0
The code goes in a regular module. I think you must have it in a sheet's code module.

Remove your existing code. Press ALT + F11 to open the VBE, select Module from the Insert menu and paste the code in there.

Mine has Option Explicit at the top because I have Require Variable Declaration checked in the VBE Tools > Options.
 
Upvote 0

Forum statistics

Threads
1,225,149
Messages
6,183,193
Members
453,151
Latest member
Lizamaison

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top