FlipEternalX
New Member
- Joined
- Mar 3, 2023
- Messages
- 24
- Office Version
- 365
- Platform
- Windows
Hi, Good day everyone.
I have concern here.
I do not want to overlap the changing of worksheet name to another color. (not based on color its just a reference)
So once I run the code, since Justin (Cleaners 1) is the last. It should be moved back to Jane, the same with Orange Tab, since Clare is the last I do not want to overlap it with Jane also, and it will get back to Aether.
Can anyone help me? Thank you so much.
Here are my VBA Code.
I have concern here.
I do not want to overlap the changing of worksheet name to another color. (not based on color its just a reference)
So once I run the code, since Justin (Cleaners 1) is the last. It should be moved back to Jane, the same with Orange Tab, since Clare is the last I do not want to overlap it with Jane also, and it will get back to Aether.
Can anyone help me? Thank you so much.
Here are my VBA Code.
VBA Code:
Private Sub Workbook_Open()
Dim OriginalDate As Date
Dim Weeks As Integer
Dim SheetNum As Integer
Dim SheetNum1 As Integer
Dim sh As Worksheet
OriginalDate = #12/10/2023#
Weeks = DateDiff("ww", OriginalDate, Now)
SheetNum = Weeks Mod Sheets.Count + 1
SheetNum1 = Weeks Mod Sheets.Count + 5
If InStr(1, Sheets(SheetNum).Name, "Cleaners 1") < 1 Then
'Workbook protection password
' ThisWorkbook.Unprotect "testpassword"
For Each sh In Sheets
sh.Name = Replace(sh.Name, " (Cleaners 1)", "")
sh.Name = Replace(sh.Name, " (Cleaners 2)", "")
Next sh
Sheets(SheetNum).Name = Sheets(SheetNum).Name & " (Cleaners 1)"
Sheets(SheetNum1).Name = Sheets(SheetNum1).Name & " (Cleaners 2)"
'ThisWorkbook.Protect Structure:=True, Windows:=False
End If
End Sub