Programs1234
08-11-2017, 11:30 AM
I am trying to "Save As" twice for a file but with a different name. However, I am having some issues issues with the last name of the code below. Please note, I left off some irrelevant codes from the program as I did not want to confuse anyone with unnecessary information
Sub credit_monitor()
Dim FileName1 As String
Dim LR As Long
Dim TaxRate As String
Dim SumAllCountries As Variant
Dim LR2 As Variant
Dim LR3 As Variant
Dim xdate As String
Dim fname As Variant
Dim fname2 As Variant
FileName1 = Workbooks("Macros").Sheets(1).Cells(7, 2)
Workbooks(FileName1).Activate
Workbooks(FileName1).Sheets(1).Select
xdate = Cells(8, 2)
FR = Range("A" & Rows.Count).End(xlUp)
xdate = Workbooks("Macros").Sheets(1).Cells(8, 2)
pth = "S:\Stock Loan\Clients\Vanguard\Reporting\Credit Monitor\"
fname = pth & "Trades as of" & " " & xdate & " " & "BBH The Chase" & ".xlsx"
Debug.Print fname
Workbooks(FileName1).SaveAs FileName:=fname, FileFormat:=xlOpenXMLWorkbook, CreateBackup:=False
Range("A1:Q1").AutoFilter
Columns(1).Delete
Columns(2).Delete
fname2 = pth & "Trades as of" & " " & xdate & " " & "Vanguard" & ".xlsx"
Debug.Print fname2
Workbooks(fname).SaveAs FileName:=fname2, FileFormat:=xlOpenXMLWorkbook, CreateBackup:=False
^ That last line has an error and spits out the "Subscript out of range" message. I would greatly appreciate any help! :)
Sub credit_monitor()
Dim FileName1 As String
Dim LR As Long
Dim TaxRate As String
Dim SumAllCountries As Variant
Dim LR2 As Variant
Dim LR3 As Variant
Dim xdate As String
Dim fname As Variant
Dim fname2 As Variant
FileName1 = Workbooks("Macros").Sheets(1).Cells(7, 2)
Workbooks(FileName1).Activate
Workbooks(FileName1).Sheets(1).Select
xdate = Cells(8, 2)
FR = Range("A" & Rows.Count).End(xlUp)
xdate = Workbooks("Macros").Sheets(1).Cells(8, 2)
pth = "S:\Stock Loan\Clients\Vanguard\Reporting\Credit Monitor\"
fname = pth & "Trades as of" & " " & xdate & " " & "BBH The Chase" & ".xlsx"
Debug.Print fname
Workbooks(FileName1).SaveAs FileName:=fname, FileFormat:=xlOpenXMLWorkbook, CreateBackup:=False
Range("A1:Q1").AutoFilter
Columns(1).Delete
Columns(2).Delete
fname2 = pth & "Trades as of" & " " & xdate & " " & "Vanguard" & ".xlsx"
Debug.Print fname2
Workbooks(fname).SaveAs FileName:=fname2, FileFormat:=xlOpenXMLWorkbook, CreateBackup:=False
^ That last line has an error and spits out the "Subscript out of range" message. I would greatly appreciate any help! :)