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

How to fill five years of quarters?
Type 1Q-2023 in a cell. Grab the fill handle and drag down or right. After 4Q-2023, Excel will jump to 1Q-2024. Dash can be any character.
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,215,343
Messages
6,124,398
Members
449,155
Latest member
ravioli44

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