Macro copy range from xlsm file to open csv file

Hudco

Board Regular
Joined
Jan 4, 2006
Messages
125
Office Version
  1. 365
I have created the following macro however it stops at "Range(B2:AI3").Select (line 5):

ChDir "C:\Wages"
Workbooks.Open Filename:="C:\FE Template.csv"
Windows("Wage Record.xlsm").Activate
Sheets("CSVUpload").Select
Range("B2:AI3").Select
Selection.Copy
Windows("FE Template.csv").Activate
Range("A2").Select
Selection.PasteSpecial Paste:=xlPasteAllUsingSourceTheme, Operation:=xlNone , SkipBlanks:=False, Transpose:=False
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks:=False, Transpose:=False
Windows("Wage Record.xlsm").Activate

Can someone please advise why it wants this line debugged?
Thank you
 

Excel Facts

Create a Pivot Table on a Map
If your data has zip codes, postal codes, or city names, select the data and use Insert, 3D Map. (Found to right of chart icons).
What is the exact error message it gives?
Are any cells in that range protected that they cannot be selected?
 
Upvote 0
What is the exact error message it gives?
Are any cells in that range protected that they cannot be selected?
Thanks for response Joe,
There are no protected cells.
The message is the standard debug - Run-time error '1004': select method of range class failed.
 
Upvote 0
What is the name of the module where you have placed this code?
Have you placed it in a Sheet module, or a General/Standard module?
 
Upvote 0
Thanks for response Joe,
There are no protected cells.
The message is the standard debug - Run-time error '1004': select method of range class failed.
Hi Joe,
I have 10 sheets in the workbook and the macro is in sheet1 under Microsoft Excel Objects. I have created an active X control button on sheet1
 
Upvote 0
Try moving it to a Standard/General module.
When trying to work across multiple sheets and files, it is best not to have the code in a Sheet module.
 
Upvote 0
Hmmm... That's not an area I have used before. I will need to do some research & training.

Thanks Joe
 
Upvote 0
Upvote 0
Solution

Forum statistics

Threads
1,215,324
Messages
6,124,249
Members
449,149
Latest member
mwdbActuary

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