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

Format cells as time
Select range and press Ctrl+Shift+2 to format cells as time. (Shift 2 is the @ sign).
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,224,731
Messages
6,180,614
Members
452,991
Latest member
JM_000888

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