I am attempting to utilize the same macro through out multiple worksheets without having to run it on every page. I found a similar thread on this topic but am having trouble getting mine to work.
I am attempting to utilize the same macro through out multiple worksheets without having to run it on every page. I found a similar thread on this topic but am having trouble getting mine to work.
Hi
The Pellroster macro really hasn't been set up to use the with / end with correctly. Much easier to just select the sheet, and then let it run from there.
rylo![]()
Sub LoopThroughSheet() Dim ws As Worksheet For Each ws In Check_Register_Details.Worksheets Call Pellroster(ws) ws.Range("A1") = ws.Name Next ws End Sub Sub Pellroster(sht As Worksheet) Dim LastRow As Long Dim lRow As Long sht.Activate 'With sht Cells.Select Selection.UnMerge With ActiveWindow .SplitColumn = 0 .SplitRow = 0 End With With Selection .HorizontalAlignment = xlLeft .Orientation = 0 .AddIndent = False .IndentLevel = 0 .ShrinkToFit = False .ReadingOrder = xlLTR .MergeCells = False End With Range("A1").Select ActiveCell.FormulaR1C1 = "campus" With ActiveCell.Characters(Start:=1, Length:=6).Font .Name = "Tahoma" .FontStyle = "Bold" .Size = 8 .Strikethrough = False .Superscript = False .Subscript = False .OutlineFont = False .Shadow = False .Underline = xlUnderlineStyleNone .ColorIndex = 4 .TintAndShade = 0 .ThemeFont = xlThemeFontNone End With Columns("A:A").Select Selection.ColumnWidth = 8 Selection.ColumnWidth = 7 Columns("C:C").Select With Selection .HorizontalAlignment = xlCenter .Orientation = 0 .AddIndent = False .IndentLevel = 0 .ShrinkToFit = False .MergeCells = False End With Columns("E:E").Select Selection.Delete Shift:=xlToLeft Columns("F:F").Select Selection.Delete Shift:=xlToLeft Columns("H:H").Select Selection.Delete Shift:=xlToLeft Range("H1").Select ActiveCell.FormulaR1C1 = "AY" With ActiveCell.Characters(Start:=1, Length:=2).Font .Name = "Tahoma" .FontStyle = "Bold" .Size = 9 .Strikethrough = False .Superscript = False .Subscript = False .OutlineFont = False .Shadow = False .Underline = xlUnderlineStyleNone .ColorIndex = 4 .TintAndShade = 0 .ThemeFont = xlThemeFontNone End With Columns("H:H").Select Selection.ColumnWidth = 5 Columns("I:I").Select With Selection .HorizontalAlignment = xlCenter .Orientation = 0 .AddIndent = False .IndentLevel = 0 .ShrinkToFit = False .MergeCells = False End With Columns("J:K").Select Selection.Delete Shift:=xlToLeft Columns("K:L").Select Selection.Delete Shift:=xlToLeft Columns("L:L").Select Selection.ColumnWidth = 11 Columns("M:M").Select Selection.Delete Shift:=xlToLeft Columns("M:M").Select Selection.ColumnWidth = 8 Columns("J:J").Select Selection.Replace What:="full time", Replacement:="FT", LookAt:=xlPart, _ SearchOrder:=xlByRows, MatchCase:=False, SearchFormat:=False, _ ReplaceFormat:=False Selection.Replace What:="HALF time", Replacement:="HT", LookAt:=xlPart, _ SearchOrder:=xlByRows, MatchCase:=False, SearchFormat:=False, _ ReplaceFormat:=False Selection.Replace What:="THREE-QUARTER time", Replacement:="3QT", LookAt _ :=xlPart, SearchOrder:=xlByRows, MatchCase:=False, SearchFormat:=False, _ ReplaceFormat:=False Selection.Replace What:="LESS THAN HALF time", Replacement:="LHT", LookAt _ :=xlPart, SearchOrder:=xlByRows, MatchCase:=False, SearchFormat:=False, _ ReplaceFormat:=False Selection.Replace What:="LESSTHAN HALF time", Replacement:="LHT", LookAt _ :=xlPart, SearchOrder:=xlByRows, MatchCase:=False, SearchFormat:=False, _ ReplaceFormat:=False Columns("J:J").Select Selection.ColumnWidth = 4 Range("A1").Select Range(Selection, Selection.End(xlToRight)).Select Range(Selection, Selection.End(xlDown)).Select ActiveWorkbook.Worksheets("Sheet1").Sort.SortFields.Clear ActiveWorkbook.Worksheets("Sheet1").Sort.SortFields.Add Key:=Range("G2:G447") _ , SortOn:=xlSortOnValues, Order:=xlAscending, DataOption:=xlSortNormal With ActiveWorkbook.Worksheets("Sheet1").Sort .SetRange Range("A1:M447") .Header = xlYes .MatchCase = False .Orientation = xlTopToBottom .SortMethod = xlPinYin .Apply End With Rows("2:2").EntireRow.AutoFit Rows("2:2").Select Range(Selection, Selection.End(xlDown)).Select Selection.RowHeight = 12.75 Range("A1").Select ActiveWindow.SmallScroll Down:=-6 Columns("G:G").Select With Selection .HorizontalAlignment = xlCenter .Orientation = 0 .AddIndent = False .IndentLevel = 0 .ShrinkToFit = False .MergeCells = False End With Columns("F:F").Select With Selection .HorizontalAlignment = xlCenter .Orientation = 0 .AddIndent = False .IndentLevel = 0 .ShrinkToFit = False .MergeCells = False End With Columns("H:H").Select With Selection .HorizontalAlignment = xlCenter .Orientation = 0 .AddIndent = False .IndentLevel = 0 .ShrinkToFit = False .MergeCells = False End With Columns("J:J").Select With Selection .HorizontalAlignment = xlCenter .Orientation = 0 .AddIndent = False .IndentLevel = 0 .ShrinkToFit = False .MergeCells = False End With Columns("A:A").ColumnWidth = 4.71 Columns("A:A").ColumnWidth = 4 Columns("A:A").Select Selection.ColumnWidth = 4 Range("A1").Select ' End With End Sub
There are currently 1 users browsing this thread. (0 members and 1 guests)
Bookmarks