Excelllllllllllllllllllll
Board Regular
- Joined
- Jun 13, 2017
- Messages
- 108
Hello guys, I'm having trouble repurposing this macro to include a new sheet ("STAFF INFO") so it sorts that sheet in the exact same way as it would the one in the macro so I don't get mismatched staff names and info.
Mind you in Rota (ORIG) I have the names of everyone working in column A whereas in STAFF INFO all of column A is pretty much a formula that references the cells in ROTA ORIG (e.g. "='ROTA (ORIG)'!A5)
Sub StaffSort()
ActiveSheet.Unprotect Password:="asd"
Range("A5:" & "BF" & Range("C1")).Select
ActiveWorkbook.Worksheets("ROTA (ORIG)").Sort.SortFields.Clear
ActiveWorkbook.Worksheets("ROTA (ORIG)").Sort.SortFields.Add Key:=Range( _
"A5:" & "A" & Range("C1").Value), SortOn:=xlSortOnValues, Order:=xlAscending, DataOption:= _
xlSortNormal
With ActiveWorkbook.Worksheets("ROTA (ORIG)").Sort
.SetRange Range("A5:" & "BF" & Range("C1"))
.Header = xlGuess
.MatchCase = False
.Orientation = xlTopToBottom
.SortMethod = xlPinYin
.Apply
End With
Range("C5").Select
ActiveSheet.Protect Password:="asd"
End Sub
Mind you in Rota (ORIG) I have the names of everyone working in column A whereas in STAFF INFO all of column A is pretty much a formula that references the cells in ROTA ORIG (e.g. "='ROTA (ORIG)'!A5)
Sub StaffSort()
ActiveSheet.Unprotect Password:="asd"
Range("A5:" & "BF" & Range("C1")).Select
ActiveWorkbook.Worksheets("ROTA (ORIG)").Sort.SortFields.Clear
ActiveWorkbook.Worksheets("ROTA (ORIG)").Sort.SortFields.Add Key:=Range( _
"A5:" & "A" & Range("C1").Value), SortOn:=xlSortOnValues, Order:=xlAscending, DataOption:= _
xlSortNormal
With ActiveWorkbook.Worksheets("ROTA (ORIG)").Sort
.SetRange Range("A5:" & "BF" & Range("C1"))
.Header = xlGuess
.MatchCase = False
.Orientation = xlTopToBottom
.SortMethod = xlPinYin
.Apply
End With
Range("C5").Select
ActiveSheet.Protect Password:="asd"
End Sub