When running my macro, I keep getting a run-time error stating the subscript is out of range. Anyone have any pointers? The line that is not working is the Application.Workbooks(3).Activate
Below is the macro..
Sub Macro1() ' ' Macro1 Macro ' ' ActiveSheet.Unprotect ActiveSheet.Name = "M-YTD" Range("E16:H16").Select Selection.MergeCells = False Columns("B:G").Select Range("G11").Activate Selection.Copy Sheets.Add After:=Sheets(Sheets.Count) ActiveSheet.Paste ActiveSheet.Name = "VarianceRpt" Rows("1:10").Select Range("A10").Activate Selection.EntireRow.Hidden = True Columns("G:G").ColumnWidth = 50 Range("G18").Select Application.CutCopyMode = False ActiveCell.FormulaR1C1 = "Variance Notes" Range("F19").Select Selection.Copy Range("G18:G19").Select Selection.PasteSpecial Paste:=xlPasteFormats, Operation:=xlNone, _ SkipBlanks:=False, Transpose:=False Application.CutCopyMode = False Range("D16:F16").Select Selection.MergeCells = True ActiveSheet.Previous.Select Range("E16:H16").Select Selection.MergeCells = True Sheets.Add After:=Sheets(Sheets.Count) ActiveSheet.Name = "Transfers" Windows("Var Template.xls").Activate Range("A1:M37").Select Selection.Copy Application.Workbooks(3).Activate ActiveSheet.Paste Sheets("VarianceRpt").Select Sheets("VarianceRpt").Move Before:=Sheets(1) End Sub
Workbooks(3). Recording a macro is a great place for beginners to get a starting point, but these tend to require a lot of editing down and tweaking to get to the final product.