Changing the sheet name to include the date

rholdren

Board Regular
Joined
Aug 25, 2016
Messages
140
Office Version
  1. 365
  2. 2019
Good morning, I am looking for a way to change the sheet name to include the date. I can get VB to rename the worksheet with the date or with the content but I can't make it do both.
for example: I have a sheet name TN_CUSTCARE. I can't seem to find a way to change the name to TN_CUSTCARE 010118 (or any date format)
I can get one or the other but not both. I have departments in four states that we track and I want to consolidate two years worth of data into one file. I could manually change them all but going forward we will be adding 2018 and beyond. I've got everything else working by VB including the importing of the files and the separation of the data but I cant get the code right to name the worksheet with both the name and date. Any help would be greatly appreciate. Thanks
 

Excel Facts

Pivot Table Drill Down
Double-click any number in a pivot table to create a new report showing all detail rows that make up that number
I can use this to name the tab with the date
Sub Sheet_name()
Sheets.Add After:=ActiveSheet
MSToday = Format(Date, "DD-MM-YY")
ActiveSheet.Name = MSToday
End Sub

And I can do this to change the name to the content
Sheets.Add After:=Sheets("Tennessee")
ActiveSheet.Name = "TN_CUSTCARE"

I have tried a variety of combinations to get both to appear with no luck. I figured I wasn't going to make it work with a combination and have been searching for ways to make it work but I seem to only find one way or the other
 
Upvote 0
Try
Code:
ActiveSheet.Name = "TN_CUSTCARE " & Format(Date, "DD-MM-YY")
 
Upvote 0
I have really got to get some glasses. It's always the little things that are giving me grief. I was missing the &
Thank you for your help. I really do appreciate it.
 
Upvote 0
Glad to help & thanks for the feedback
 
Upvote 0

Forum statistics

Threads
1,224,823
Messages
6,181,181
Members
453,022
Latest member
Mohamed Magdi Tawfiq Emam

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