Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
45 changes: 45 additions & 0 deletions VBA/VBA-Code_By_Modules/DuplicateActualRoster.bas
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
Attribute VB_Name = "DuplicateActualRoster"
Sub DuplicateActualRoster()
Dim srcSheet As Worksheet
Dim copySheet As Worksheet
Dim sheetName As String
Dim enteredPassword As String
Const password As String = "rostering2025"

enteredPassword = InputBox("Please enter the password to duplicate the roster:", "Password Authentication")
If enteredPassword <> password Then
MsgBox "Incorrect password. Duplicate operation declined.", vbCritical
Exit Sub
End If

Set srcSheet = Sheets("Roster")
sheetName = "ActualRoster_" & Format(Now, "yyyymmdd_hhnn")

srcSheet.Copy After:=Sheets(Sheets.count)
Set copySheet = ActiveSheet
copySheet.Name = sheetName

'With srcSheet.UsedRange
' .Copy Destination:=copySheet.Range("A1")
'End With

' Remove all shapes (e.g., buttons, form controls, etc.)
For Each shp In copySheet.Shapes
shp.Delete
Next shp

With copySheet.Cells
.Locked = True
End With

copySheet.Protect password:="nuslib2017@52", _
AllowSorting:=True, _
AllowFiltering:=True, _
AllowFormattingCells:=True


srcSheet.Activate

End Sub


43 changes: 43 additions & 0 deletions VBA/VBA-Code_By_Modules/DuplicateSystemRoster.bas
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
Attribute VB_Name = "DuplicateSystemRoster"
Sub DuplicateSystemRoster()
Dim srcSheet As Worksheet
Dim copySheet As Worksheet
Dim sheetName As String

Set wsRoster = Sheets("Roster")
Set srcSheet = wsRoster
sheetName = "SystemRoster_" & Format(Now, "yymmdd_hhnn")

'Copy the whole sheet
srcSheet.Copy After:=Sheets(Sheets.count)
Set copySheet = ActiveSheet
copySheet.Name = sheetName

'With srcSheet.UsedRange
' copySheet.Range("A1").Resize(.Rows.Count, .Columns.Count).Value = .Value
' Application.CutCopyMode = False
'End With

' Remove all shapes (e.g., buttons, form controls, etc.)
For Each shp In copySheet.Shapes
shp.Delete
Next shp

With copySheet.Cells
.Locked = True
End With

copySheet.Protect password:="nuslib2017@52", _
AllowSorting:=True, _
AllowFiltering:=True, _
AllowFormattingCells:=True

wsRoster.Activate

End Sub