Copying cells from one workbook to another and saving an individual file for each cell

Andyg666

New Member
Joined
Apr 24, 2024
Messages
27
Office Version
  1. 365
Platform
  1. Windows
Hi,
I am new to macros but hope you can help me.
I have a list of items and related information (model, serial number etc) and I need a macro so that I can press a button and export the item name and serial number of each item into another workbook for each item on the original list including a pop up option of where these new workbooks would be saved.

I hope this makes sense, please help
 
Thanks ........ however it works for the first for lines but then gives an error
Run-time error '1004':
Method 'saveAs' of object '_Workbook' failed
ERROR.png

What is this then? As you can tell I am clueless :)
 
Upvote 0

Excel Facts

Control Word Wrap
Press Alt+Enter to move to a new row in a cell. Lets you control where the words wrap.
Make sure that the data in C3 & C4 & C5 & H3 does not reproduce duplicate file names.
 
Upvote 0
Thanks ........ however it works for the first for lines but then gives an error
Run-time error '1004':
Method 'saveAs' of object '_Workbook' failed
View attachment 114593
What is this then? As you can tell I am clueless :)
Hi,
I think the file name is to long and i gives this error and then stops
Make sure that the data in C3 & C4 & C5 & H3 does not reproduce duplicate file names.
Hi,
I'm thinking the file name is to long and it gives this error and then stops
 
Upvote 0
You can have up to 260 characters including the extension so I don't think that's the problem. Did you delete the question marks? Are any files being saved?
 
Upvote 0
You can have up to 260 characters including the extension so I don't think that's the problem. Did you delete the question marks? Are any files being saved?

It is the file name length
If I change the name in the data file so its no as long it works until it gets to the next error.

I don't think the file name would of been 260 characters long but I would need to check but if I go to the file it created and rename to put the longer file name in manually it works. ????

Yes I have removed all the question marks.
 
Upvote 0
I removed all the question marks and ran the macro and it created all 7 files correctly using the 2 files you posted. Are you using the macro on different files?
 
Upvote 0
I removed all the question marks and ran the macro and it created all 7 files correctly using the 2 files you posted. Are you using the macro on different files?
it works but then has an issue with the filename length as when I reuse the text in the data then it works and moves on to the next.

The file length is about 99 characters????
 
Upvote 0
It should accept up to 260 characters.
 
Upvote 0
I removed one of the cells (c5) and its busy doing its thing now.
Not 100% I have done that correctly but I will update
It may be because it includes the file path name in the character limit?
 
Upvote 0

Forum statistics

Threads
1,221,537
Messages
6,160,401
Members
451,645
Latest member
hglymph

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