Evernight2021
New Member
- Joined
- Dec 28, 2018
- Messages
- 10
I'm attempting to create a button that when pressed will copy the current sheet to the end of the sheet list and rename it using some predefined text as well as incremented data from one cell.
The cell is A1 and will contain a year. I want to have the new tab be renamed to 'Schedule 2019' when pressed (pulling the 2019 from cell A1 in the 'Schedule 2018' sheet and incrementing it by 1), and when pressed in the 'Schedule 2019' sheet, create a 'Schedule 2020' sheet and so on.
I have successfully written the code to create the sheet and rename it using just the data from the cell, however I can't seem to figure out how to include the 'Schedule' portion before it. I'm also wondering if it's possible to have the year in A1 automatically increment by one on the copied sheet so the year will be correct.
The code I'm working with now is as follows:
Any assistance you can provide will be greatly appreciated!
The cell is A1 and will contain a year. I want to have the new tab be renamed to 'Schedule 2019' when pressed (pulling the 2019 from cell A1 in the 'Schedule 2018' sheet and incrementing it by 1), and when pressed in the 'Schedule 2019' sheet, create a 'Schedule 2020' sheet and so on.
I have successfully written the code to create the sheet and rename it using just the data from the cell, however I can't seem to figure out how to include the 'Schedule' portion before it. I'm also wondering if it's possible to have the year in A1 automatically increment by one on the copied sheet so the year will be correct.
The code I'm working with now is as follows:
Code:
[FONT=Verdana,Arial,Tahoma,Calibri,Geneva,sans-serif]Private Sub CommandButton1_Click()
ActiveSheet.Copy after:=Sheets(Worksheets.Count)
With ActiveSheet
.Name = .Range("A1").Value
End With
End Sub
[/FONT]
Any assistance you can provide will be greatly appreciated!