Macro to open a workbook and copy info to another workbook

nularry

New Member
Joined
Sep 5, 2011
Messages
13
Office Version
  1. 365
Platform
  1. Windows
I am trying to create a simple macro, I thought. This will be a Personal macro so I can use it for any workbook. Basically I will save an inventory excel file on my computer. Then open it and what I want is to
Open another excel file (my master) and copy 3 columns from here and insert/paste them onto the inventory workbook.

Every time I try it stops at opening the (master) workbook and does nothing else.
Any help would be great.

Here's the code I got:

Sub Macro1()
'
' Macro1 Macro
' Macro recorded 9/5/2011 by Larry Ross
'
' Keyboard Shortcut: Ctrl+Shift+I
'
Range("D11").Select
ChDir "C:\Users\Larry\Documents\Inventory"
Workbooks.Open Filename:="C:\Users\Larry\Documents\Inventory\master.pmix.xls"
Columns("C:E").Select
Selection.Copy
Windows("inv.pmx.csv").Activate
Columns("D:D").Select
Selection.Insert Shift:=xlToRight
Columns("C:C").EntireColumn.AutoFit
Rows("11:11").Select
Application.CutCopyMode = False
Selection.Delete Shift:=xlUp
Range("D8").Select
End Sub
 
Last edited:

Excel Facts

Using Function Arguments with nested formulas
If writing INDEX in Func. Arguments, type MATCH(. Use the mouse to click inside MATCH in the formula bar. Dialog switches to MATCH.
Try removing this line (or comment out):
Code:
ChDir "C:\Users\Larry\Documents\Inventory"
 
Upvote 0
Thanks JoeMo. I did that initially thinking it was the error. I actually deleted the first 2 lines also. Still no good. I am using Excel 2003. I am sure I have done this before but can not figure out why it wont work now.
 
Upvote 0
The code looks ok, but something may be corrupted. Try re-typing the code in a new module.
 
Upvote 0

Forum statistics

Threads
1,224,504
Messages
6,179,142
Members
452,892
Latest member
JUSTOUTOFMYREACH

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