Macro/VBA to copy a range of data from a worksheet to a new workbook

oosag23

New Member
Joined
Dec 11, 2018
Messages
9
Please,can someone help me write a macro.
I have an“A.xls” workbook where I want to open then copy a range of data to “B.xlsx” file.

B.xlsxfile has the same format as a.xls so the data being copied will fit the samerange.

I then want to password protect the new workbook (B.xlsx) and rename andsave it as A.xlsx (same title as “A.xls” file). I need this to repeat for 400files that need this change.

Is it possible to dynamically
make this macro to fit for the next files eg. (A-1.xls to B-1.xlsx renamed to A-1.xlsx)

Anyassistance would be much appreciated.
 

Excel Facts

Copy formula down without changing references
If you have =SUM(F2:F49) in F50; type Alt+' in F51 to copy =SUM(F2:F49) to F51, leaving the formula in edit mode. Change SUM to COUNT.
Check the file that has the problem. You must remove it from your folder.
Or add this instruction to the start of the macro: On error resume next
 
Upvote 0

Forum statistics

Threads
1,214,632
Messages
6,120,655
Members
448,975
Latest member
sweeberry

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