Creating new tabs from a template and renaming tabs with the date

dami916

New Member
Joined
Jan 5, 2018
Messages
7
Hello,
I'm making the schedule for my employees and I was wondering if there is a macro that would automatically create a tab with a template for the next week and rename that tab with the date of that week.
Thank you

Mon
Tue
Wed
Thu
Fri
Sat
Sun
1/1/2018
1/2/2018
1/3/2018
1/4/2018
1/5/2018
1/6/2018
1/7/2018
Position1
current
YTD
relief
YTD
employee 1
off
off
Position2
employee 2
off
off
employee 3
off
off
employee 4
off
off
Position3
employee 6
off
off
employee 7
off
off
Position4
employee 8
off
off
employee 9
off
off
employee 10
off
off
employee 11
off
off
employee 12
off
off
employee 13
off
off
employee 14
off
off
employee 15
off
off
employee 16
off
off
employee 17
off
off
employee 18
off
off
employee 19
off
off
section1
section2
section3
section4
section5
section6
section7
section8
1234
5678

<tbody>
</tbody>
 

Excel Facts

Add Bullets to Range
Select range. Press Ctrl+1. On Number tab, choose Custom. Type Alt+7 then space then @ sign (using 7 on numeric keypad)
.
Code:
Option Explicit


Sub CreateNew()
Dim wsRecipes As Worksheet, wsTEMP As Worksheet, wasVISIBLE As Boolean
Dim shNAMES As Range, Nm As Range
Dim i As Long
Dim wsIndex
On Error Resume Next




With ThisWorkbook                                               'keep focus in this workbook
Application.CopyObjectsWithCells = False
    Set wsTEMP = .Sheets("Template")                            'sheet to be copied
    wasVISIBLE = (wsTEMP.Visible = xlSheetVisible)              'check if it's hidden or not
    If Not wasVISIBLE Then wsTEMP.Visible = xlSheetVisible      'make it visible
      
    Application.ScreenUpdating = False                          'speed up macro


    wsTEMP.Copy After:=.Sheets(.Sheets.Count)                   '...create it from template
    
    wsIndex.Activate                                            'return to the master sheet
    If Not wasVISIBLE Then wsTEMP.Visible = xlSheetHidden       'hide the template if necessary
    Application.ScreenUpdating = True                           'update screen one time at the end


Application.CopyObjectsWithCells = True
End With
Sheets(Sheets.Count).Select


Dim szTodayDate As String
szTodayDate = Format(Date + 7, "mm-dd-yy") & "  to  " & Format(Date + 13, "mm-dd-yy")
ActiveSheet.Name = szTodayDate
MsgBox "New sheet created. "
End Sub


Download : https://www.amazon.com/clouddrive/share/X4i7rKE0NYBSB8RFy2w4b2RH1BXf2HN6G4xjISID5vw
 
Upvote 0

Forum statistics

Threads
1,214,918
Messages
6,122,246
Members
449,075
Latest member
staticfluids

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