I had great help with the last six lines of this code on this site, it works great as its own sub but when I added it to an existing VBA it only renames one tab. Any ideas what I am doing wrong when I am combining these two working VBA's.
Code:
Sub Sat_School_Genisis()
'
' Sat_School_Genisis Macro
'
'
Columns("A:V").Select
Selection.Delete Shift:=xlToLeft
Selection.ColumnWidth = 19.67
Columns("B:B").Select
Selection.Delete Shift:=xlToLeft
Columns("D:E").Select
Selection.Delete Shift:=xlToLeft
Columns("E:E").Select
Selection.Delete Shift:=xlToLeft
Columns("F:L").Select
Selection.Delete Shift:=xlToLeft
Columns("E:E").Select
Selection.Cut Destination:=Columns("F:F")
Columns("D:D").Select
Selection.TextToColumns Destination:=Range("D1"), DataType:=xlDelimited, _
TextQualifier:=xlDoubleQuote, ConsecutiveDelimiter:=False, Tab:=False, _
Semicolon:=False, Comma:=True, Space:=False, Other:=False, FieldInfo _
:=Array(Array(1, 1), Array(2, 1))
Columns("E:E").Select
Selection.Delete Shift:=xlToLeft
ActiveWindow.SmallScroll Down:=-37
With ActiveSheet
.AutoFilterMode = False
With Range("a1", Range("a" & Rows.Count).End(xlUp))
.AutoFilter 1, 0
On Error Resume Next
.Offset(1).SpecialCells(12).EntireRow.Delete
End With
.AutoFilterMode = False
End With
Range("A1").Select
Selection.CurrentRegion.Select
Selection.Copy
Sheets.Add
ActiveSheet.Paste
Sheets.Add
ActiveSheet.Paste
ActiveWindow.SmallScroll Down:=-68
Sheet1.Select
Range("A1").Select
Selection.CurrentRegion.Select
ActiveWorkbook.Worksheets("34033e21-0dd7-4480-ab77-683d72e").Sort.SortFields. _
Clear
ActiveWorkbook.Worksheets("34033e21-0dd7-4480-ab77-683d72e").Sort.SortFields. _
Add Key:=Range("E2:E631"), SortOn:=xlSortOnValues, Order:=xlAscending, _
DataOption:=xlSortNormal
ActiveWorkbook.Worksheets("34033e21-0dd7-4480-ab77-683d72e").Sort.SortFields. _
Add Key:=Range("D2:D631"), SortOn:=xlSortOnValues, Order:=xlAscending, _
DataOption:=xlSortNormal
With ActiveWorkbook.Worksheets("34033e21-0dd7-4480-ab77-683d72e").Sort
.SetRange Range("A1:E631")
.Header = xlYes
.MatchCase = False
.Orientation = xlTopToBottom
.SortMethod = xlPinYin
.Apply
End With
ActiveWindow.SmallScroll Down:=-215
Sheets("Sheet1").Select
Range("A1").Select
Selection.CurrentRegion.Select
ActiveWorkbook.Worksheets("Sheet1").Sort.SortFields.Clear
ActiveWorkbook.Worksheets("Sheet1").Sort.SortFields.Add Key:=Range("C2:C631") _
, SortOn:=xlSortOnValues, Order:=xlAscending, DataOption:=xlSortNormal
With ActiveWorkbook.Worksheets("Sheet1").Sort
.SetRange Range("A1:E631")
.Header = xlYes
.MatchCase = False
.Orientation = xlTopToBottom
.SortMethod = xlPinYin
.Apply
End With
Columns("C:C").Select
Columns("C:C").Cut Destination:=Columns("A:A")
Columns("C:E").Select
Selection.Delete Shift:=xlToLeft
Sheets("Sheet2").Select
Columns("A:A").Select
Selection.ClearContents
Columns("C:F").Select
Selection.Delete Shift:=xlToLeft
Range("A1").Select
ActiveCell.FormulaR1C1 = "Group"
Range("A2").Select
ActiveCell.FormulaR1C1 = "PHS-West Saturday School"
Range("A2").Select
Selection.AutoFill Destination:=Range("A2:A631")
Range("A2:A631").Select
Range("B1").Select
ActiveCell.FormulaR1C1 = "ReferenceCode"
Range("C8").Select
' Sort_by_room Macro
'
'
Cells.Select
Sheet1.Sort.SortFields. _
Clear
Sheet1.Sort.SortFields. _
Add Key:=Range("E2:E631"), SortOn:=xlSortOnValues, Order:=xlAscending, _
DataOption:=xlSortNormal
Sheet1.Sort.SortFields. _
Add Key:=Range("D2:D631"), SortOn:=xlSortOnValues, Order:=xlAscending, _
DataOption:=xlSortNormal
With Sheet1.Sort
.SetRange Range("A1:E631")
.Header = xlYes
.MatchCase = False
.Orientation = xlTopToBottom
.SortMethod = xlPinYin
.Apply
End With
Dim myDate As Date, aDate
myDate = Date + 7 - Weekday(Date)
aDate = Format(myDate, "mm.dd.yyyy")
Sheet1.Name = "Mail Merge" & aDate
Sheet2.Name = "Phone" & aDate
Sheet3.Name = "Roster" & aDate
End Sub