stillenacht
New Member
- Joined
- Nov 16, 2015
- Messages
- 6
Hey all, for some reason my VBA code sometimes works, but sometimes spits out "Run-time error '1004': Application-defined or object-defined error".
The section that causes trouble is always this one, specifically the select line:
'Entering Stocks from IB Report
Dim Report As Workbook
Set Report = Application.Workbooks("IB_statement.csv")
Report.Sheets("IB_statement").Range(Range("D29"), Range("D29").End(xlDown)).Select
Selection.Copy
Analysis.Sheets("Profit Calculations").Range("C3").PasteSpecial
The rest of the code is copying things from xlsx files, so I wonder if that's causing the issue. On more testing, it looks like it runs fine if i have the IB_statement file open AND selected.
The section that causes trouble is always this one, specifically the select line:
'Entering Stocks from IB Report
Dim Report As Workbook
Set Report = Application.Workbooks("IB_statement.csv")
Report.Sheets("IB_statement").Range(Range("D29"), Range("D29").End(xlDown)).Select
Selection.Copy
Analysis.Sheets("Profit Calculations").Range("C3").PasteSpecial
The rest of the code is copying things from xlsx files, so I wonder if that's causing the issue. On more testing, it looks like it runs fine if i have the IB_statement file open AND selected.
Last edited: