VBA SaveAs Error

Cagey93

New Member
Joined
Apr 17, 2019
Messages
28
Hello,

I am trying to automate some data importing into a spreadsheet from another then save as a new file name.

When I go through the macro it all works right up to the point it trys to save the spreadsheet.

I just get the run time error 424: Object required

I am sure I must be missing something but unsure as to what?

Please could someone assist?

Code:
Sub CopyDate()


Dim inputdata As String
Dim outputdata As String
Dim moveto As String
Dim oFSO As Object


inputdata = Sheets("Variables").Range("B1")  
outputdata = Sheets("Variables").Range("B2")
moveto = Sheets("Variables").Range("B3") 


Workbooks.Open (inputdata)



    'Copy LIBOR 30Y forward curve
    
    Sheets("libor 1m1m 30yrs").Select
    Range("A11:C369").Select
    Selection.Copy
    Windows("Daily Valuation.xlsm").Activate
    Worksheets("Yield Curve").Activate
    Range("B3").Select
    ActiveSheet.Paste
    
    'Copy spot for LIBOR curve
    
    Windows("Try_Acc_DailyVALS.xlsx").Activate
    Range("B10").Select
    Application.CutCopyMode = False
    Selection.Copy
    Windows("Daily Valuation.xlsm").Activate
    Worksheets("Yield Curve").Activate
    Range("D2").Select
    ActiveSheet.Paste
    
    'Copy spot rate for SONIA curve
    
    Windows("Try_Acc_DailyVALS.xlsx").Activate
    Sheets("sonia 1m1m 30yrs").Select
    Range("B10").Select
    Application.CutCopyMode = False
    Selection.Copy
    Windows("Daily Valuation.xlsm").Activate
    Worksheets("Yield Curve").Activate
    Range("J2").Select
    ActiveSheet.Paste
    
    'Copy SONIA 30Y forward curve
    
    Windows("Try_Acc_DailyVALS.xlsx").Activate
    Range("A11:C369").Select
    Application.CutCopyMode = False
    Selection.Copy
    Windows("Daily Valuation.xlsm").Activate
    Worksheets("Yield Curve").Activate
    Range("H3").Select
    ActiveSheet.Paste
    
    'Copy EUR-GBP 30Y forward rate
    
    Sheets("fx rates").Select
    Windows("Try_Acc_DailyVALS.xlsx").Activate
    Sheets("GBP EUR FWD 5Y").Select
    Range("B10:F27").Select
    Application.CutCopyMode = False
    Selection.Copy
    Windows("Daily Valuation.xlsm").Activate
    Worksheets("fx rates").Activate
    Range("C5").Select
    ActiveSheet.Paste


Workbooks("Try_Acc_DailyVALS.xlsx").Close


'Save the model for todays date in xlsx format


Workbook.SaveAs Filename:=outputdata


'Move output to control folder


Set oFSO = CreateObject("Scripting.FileSystemObject")
oFSO.MoveFile outputdata, moveto
FSO_MoveFile = True


Application.Quit


End Sub
 

Some videos you may like

Excel Facts

What is the last column in Excel?
Excel columns run from A to Z, AA to AZ, AAA to XFD. The last column is XFD.

bobrandt

New Member
Joined
Feb 1, 2018
Messages
1
Office Version
365, 2016, 2013, 2011, 2010, 2007
Platform
Windows
You're not specifying which workbook you want to save.
The following would save Daily Valuation.xlsm using the new filename.
Code:
[COLOR=#333333]Workbooks([/COLOR][COLOR=#333333]"Daily Valuation.xlsm")[/COLOR][COLOR=#333333].SaveAs Filename:=outputdata[/COLOR]
 

Cagey93

New Member
Joined
Apr 17, 2019
Messages
28
You're not specifying which workbook you want to save.
The following would save Daily Valuation.xlsm using the new filename.
Code:
[COLOR=#333333]Workbooks([/COLOR][COLOR=#333333]"Daily Valuation.xlsm")[/COLOR][COLOR=#333333].SaveAs Filename:=outputdata[/COLOR]
I knew it would be something simple that has worked thank you very much.
 

Watch MrExcel Video

Forum statistics

Threads
1,099,567
Messages
5,469,453
Members
406,652
Latest member
LJA

This Week's Hot Topics

Top