Automating create copy of current tab with date

JumboCactuar

Well-known Member
Joined
Nov 16, 2016
Messages
785
Office Version
  1. 365
Platform
  1. Windows
Hi,
i have a current tab with mondays date in cell A1 like 13/08/18 and the tab is named 13.08.18

how can i with VBA, create a copy into new tabs for every week in the year (or a specified amount)

i.e next tab will have 20/08/2018 with tab name 20.08.18

thanks for any help
 

Excel Facts

Best way to learn Power Query?
Read M is for (Data) Monkey book by Ken Puls and Miguel Escobar. It is the complete guide to Power Query.
Are you saying you have
13.08.18
In Range("A1")
And you want to make 52 copies of this sheet.

And give them names like 13.15.18 and next copy named 22.08.18 and so on?
 
Last edited:
Upvote 0
My mistake it would be:
And give them names like 13.15.18 and next copy named 20.08.18 and so on?
 
Upvote 0
Yes correct though the date in cell A1 is formatted as DD/MM/YYYY

52 would be good, or maybe an input for how many copies to replicate

13.08.18
20.08.18
27.08.18
03.09.18
...
 
Last edited:
Upvote 0
Was thinking something like

date1 = range("A1).value

After loop or next ws

date1 = date1 +7
 
Upvote 0
On the right track I think, just need a loop

Code:
Sub Test()
With ActiveSheet
ShName = Range("A1").Value +7
.Copy After:=Sheets(Worksheets.Count)
End With
Sheets(Worksheets.Count).Name = ShName
Sheets(Worksheets.Count).Activate
Sheets(Worksheets.Count).Range("A1").Value = ShName

'loop

End Sub
 
Upvote 0
^ no luck with the above, adds new sheet but trouble with the renaming

ffdc78cd67.png
 
Upvote 0
Try this:
Sheet names cannot have a / I'm using a -

Code:
Sub Sheet_Copy()
'Modified  8/15/2018  9:45:42 PM  EDT
Application.ScreenUpdating = False
Dim ans As Variant
ans = InputBox("Make how many copies")
If ans = "" Then MsgBox "You did not enter a number": Exit Sub
    For i = 1 To ans
        Sheets("13.08.18").Copy after:=Sheets(Sheets.Count)
        ActiveSheet.Name = Format(DateAdd("d", i * 7, "8/13/2018"), "DD-MM-YYYY")
    Next

Application.ScreenUpdating = True
End Sub
 
Last edited:
Upvote 0
Try this:
Sheet names cannot have a / I'm using a -

Code:
Sub Sheet_Copy()
'Modified  8/15/2018  9:45:42 PM  EDT
Application.ScreenUpdating = False
Dim ans As Variant
ans = InputBox("Make how many copies")
If ans = "" Then MsgBox "You did not enter a number": Exit Sub
    For i = 1 To ans
        Sheets("13.08.18").Copy after:=Sheets(Sheets.Count)
        ActiveSheet.Name = Format(DateAdd("d", i * 7, "8/13/2018"), "DD-MM-YYYY")
    Next

Application.ScreenUpdating = True
End Sub

Thank you :)

This works perfectly
 
Upvote 0
Glad I was able to help you.
Come back here to Mr. Excel next time you need additional assistance.
 
Upvote 0

Forum statistics

Threads
1,214,606
Messages
6,120,484
Members
448,967
Latest member
visheshkotha

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