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
 

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
  1. 365
  2. 2016
  3. 2013
  4. 2011
  5. 2010
  6. 2007
Platform
  1. 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.
 
Master Excel Bundle

Excel contains over 450 functions, with more added every year. That’s a huge number, so where should you start? Right here with this bundle.

Forum statistics

Threads
1,152,255
Messages
5,769,067
Members
425,515
Latest member
baltusf

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
Top