Programs1234
08-24-2017, 10:49 AM
Alright, i got some code here that does not work. Can anyone help me fix this. The error box keeps shooting out the message either "subscript outta range" or "Save as" error. Error happens in the LAST LINE
Please see the code below:
Sub CATReport()
Dim filename3 As Variant
Dim LR3 As Integer
Dim column_in_review_2 As Variant
Dim rownumber As Integer
Dim mydate As Date
Dim currentdate As Variant
Dim fname3 As Variant
Dim filename4 As Variant
'Attach Buttons from Macro sheet
LR3 = Range("AC" & Rows.Count).End(xlUp).Row
Application.DisplayAlerts = False
Workbooks("Macros").Activate
filename3 = Workbooks("Macros").Sheets(1).Cells(15, 2)
Workbooks("Macros").Activate
currentdate = Workbooks("Macros").Sheets(1).Cells(16, 2)
Workbooks(filename3).Activate
''''''''''Irrelevant code'''''''''''''''
pth = "S:\Stock Loan\CPM\CATS\Reporting\Nightly File\2017\"
fname3 = pth & "CorporateActionsTrackerNightly" & "_" & currentdate & "_Internal Only" & ".xlsx"
Debug.Print fname3
Workbooks(filename3).SaveAs FileName:=fname3, FileFormat:=xlOpenXMLWorkbook, CreateBackup:=False
End Sub
Please see the code below:
Sub CATReport()
Dim filename3 As Variant
Dim LR3 As Integer
Dim column_in_review_2 As Variant
Dim rownumber As Integer
Dim mydate As Date
Dim currentdate As Variant
Dim fname3 As Variant
Dim filename4 As Variant
'Attach Buttons from Macro sheet
LR3 = Range("AC" & Rows.Count).End(xlUp).Row
Application.DisplayAlerts = False
Workbooks("Macros").Activate
filename3 = Workbooks("Macros").Sheets(1).Cells(15, 2)
Workbooks("Macros").Activate
currentdate = Workbooks("Macros").Sheets(1).Cells(16, 2)
Workbooks(filename3).Activate
''''''''''Irrelevant code'''''''''''''''
pth = "S:\Stock Loan\CPM\CATS\Reporting\Nightly File\2017\"
fname3 = pth & "CorporateActionsTrackerNightly" & "_" & currentdate & "_Internal Only" & ".xlsx"
Debug.Print fname3
Workbooks(filename3).SaveAs FileName:=fname3, FileFormat:=xlOpenXMLWorkbook, CreateBackup:=False
End Sub