Rename the last spreadsheet name based on previous date VBA

Panoos64

Well-known Member
Joined
Mar 1, 2014
Messages
882
Hi to all of you!
I would like to use a VBA code so that to rename the last spreadsheet's name which is "Checkin" and is in the right, into date based on previous spreadsheet.
E.g. Previous spreadsheet date: 16.07.23
Spreadsheet name "Checkin" rename to 17.07.23
Thank you all in advance
 

Excel Facts

Test for Multiple Conditions in IF?
Use AND(test, test, test, test) or OR(test, test, test, ...) as the logical_test argument of IF.
Try this

VBA Code:
Sub Name_Last_Sheet()
  Sheets(Sheets.Count).Name = Format(DateValue(Replace(Sheets(Sheets.Count - 1).Name, ".", "/")) + 1, "dd.mm.yy")
End Sub
 
Upvote 0
Try this

VBA Code:
Sub Name_Last_Sheet()
  Sheets(Sheets.Count).Name = Format(DateValue(Replace(Sheets(Sheets.Count - 1).Name, ".", "/")) + 1, "dd.mm.yy")
End Sub
Thank you Peter! It works perfect and according to my data. Hv a great day!!
 
Upvote 0
You're welcome. Thanks for the confirmation. :)
 
Upvote 0

Forum statistics

Threads
1,215,107
Messages
6,123,126
Members
449,097
Latest member
mlckr

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