How to copy a worksheet and update a cell showing the date in increments

DaOriginalExcel

New Member
Joined
Sep 17, 2024
Messages
2
Office Version
  1. 365
Platform
  1. Windows
Hello, I am trying to come up with a function or a VBA macro that is able to automatically update a cell with the next days date (based off previous worksheet) on the newly copied shoot

Example: make a copy of the current worksheet (Sept 8), but the date in cell B1 updates incrementally to Sept 9 on the new copied one. All else stays the same as well as being able to do it for days in advance.

Does anyone know how to go about this? Appreciate the help!
 

Excel Facts

Show numbers in thousands?
Use a custom number format of #,##0,K. Each comma after the final 0 will divide the displayed number by another thousand
VBA Code:
Sub NextDaySheet()
    ActiveSheet.Copy After:=ActiveSheet
    Range("B1").Value = Range("B1").Value + 1
End Sub
 
Upvote 0
Solution
The date is just a number, so in a macro you use to copy a sheet you can just add +1 to cell B1 value


Edit: whoops, it's already in the post published by AlphaFrog a minute ago while I was writing this one
 
Upvote 0
VBA Code:
Sub NextDaySheet()
    ActiveSheet.Copy After:=ActiveSheet
    Range("B1").Value = Range("B1").Value + 1
End Sub
Great Thanks! Sorry im new to VBA so this is very helpful. If I wanted to rename the newly copied sheet to Say "Sept 9", how would you do that if you can?

I tried setting a value to B1 and renaming ActiveSheet but it isnt working.

Thanks Again!
 
Upvote 0
VBA Code:
Sub NextDaySheet()
    ActiveSheet.Copy After:=ActiveSheet
    Range("B1").Value = Range("B1").Value + 1
    On Error Resume Next
    ActiveSheet.Name = Format(Range("B1").Value, "mmm d")
    If Err.Number <> 0 Then MsgBox Format(Range("B1").Value, "mmm d"), _
        vbExclamation, "Sheet Name Already Exists!"
End Sub
 
Upvote 0

Forum statistics

Threads
1,221,533
Messages
6,160,383
Members
451,645
Latest member
hglymph

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