Using VBA to rename worksheets

JGB284

New Member
Joined
Sep 29, 2022
Messages
2
Office Version
  1. 365
Platform
  1. MacOS
Hi- I am a long term Excel user but with limited VBA knowledge.
In simplified terms, I have a workbook where on the first worksheet I have a set of financial data to be input into 4 columns - say B, C, D and E. The cumulative data fro each month is carried forward each day on a separate worksheet. The Headers are on row 3 and brought forward figures from the previous day are on row 4. Data input starts on row 5 and goes down to row 49. Row 50 is set up with totals for the four columns. The worksheet needs to be renamed for the date of the transactions for example - 1st October. Before the next day I need to create a copy of the previous day's template and bring forward the data from row 50 on the previous day and place it in row 4 as the brought forward totals and clear the contents of the previous day's transactions ready to input the data for the new day.
I have prepared some VBA code to do this task which works fine. What I would also like it to do is use VBA to rename the worksheet tab by reference to the previous day - so in this instance I would want the worksheet name tab to be 2nd October etc etc through the month.
Many Thanks
 

Excel Facts

What is the last column in Excel?
Excel columns run from A to Z, AA to AZ, AAA to XFD. The last column is XFD.
Hi there and welcome to the forum

There are several ways to rename sheets... depends on if you want to do it manually or with a button etc... Maybe provide us on how you want to approach renaming? Should it be done after a change or according to a cell value? See different options below:

VBA Code:
Sheets("Sheet1").name = Range("A1").Value ‘Using sheet name

Activesheet.Name = "mySheet" ‘Renames activesheet

Sheets(5).Name = "mySheet5" ‘Renames sheet via sheet codename

Sheets("Sheet1").name = Range("A1").Value ‘Renames sheet with value in a cell
 
Upvote 0
Hi there and welcome to the forum

There are several ways to rename sheets... depends on if you want to do it manually or with a button etc... Maybe provide us on how you want to approach renaming? Should it be done after a change or according to a cell value? See different options below:

VBA Code:
Sheets("Sheet1").name = Range("A1").Value ‘Using sheet name

Activesheet.Name = "mySheet" ‘Renames activesheet

Sheets(5).Name = "mySheet5" ‘Renames sheet via sheet codename

Sheets("Sheet1").name = Range("A1").Value ‘Renames sheet with value in a cell
Many thanks for you prompt response - that is helpful
 
Upvote 0

Forum statistics

Threads
1,214,399
Messages
6,119,279
Members
448,884
Latest member
chuffman431a

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