Cagey93

New Member
Joined
Apr 17, 2019
Messages
34
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
 

Excel Facts

When they said...
When they said you are going to "Excel at life", they meant you "will be doing Excel your whole life".
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]
 
Upvote 0
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.
 
Upvote 0

Forum statistics

Threads
1,213,565
Messages
6,114,338
Members
448,570
Latest member
rik81h

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top