Hey everyone, this is my first post here, probably not my last
I'm trying to write a simple macro to copy selected rows from one workbook and insert the copied rows into another workbook. The rows I need to select and copy will vary from day to day. Here's my code so far:
Sub ContractorsTab()
Workbooks.Open Filename:="X:\OSC DETAIL\Invoices Sent to AP\Sent Invoice Summary - 2012.xlsx"
Selection.Copy
Windows("Sent Invoice Summary - 2012.xlsx").Activate
Sheets("Contractors").Select
Rows("4:4").Select
Selection.Insert Shift:=xlDown
Windows("OS Invoices 07-15.xlsm").Activate
End Sub
My problem is the first line. Without it, this macro works fine if I already have the workbook I need to copy to open, but I'm trying to insert a little more code so the macro will automatically open up the workbook I'm inserting the copied rows to, then save and close. Obviously I haven't gotten to the save, close part yet, but I'm wondering if anyone could give me a little guidance on what is causing my error with the code above. The workbook opens fine with the above code, but then I get an error saying the "Selection.Insert Shift:=xlDown" line is not allowed because it is attempting to shift cells in a table on my worksheet. Why am I getting this error? The code worked flawlessly before I added the first line of code telling Excel to open my Sent Invoice Summary - 2012 workbook. Ever since adding in that piece of code, it isn't allowing the insert rows line to function. Anyone know what I'm missing or need to adjust? Thanks!
-Eric
Bookmarks