Paste filename into spreadsheet

Duncgee

Board Regular
Joined
Oct 7, 2002
Messages
73
I have a number of workbooks from which a macro copies data. This data is then pasted into another workbook. How can I have the macro paste the filenames as well as the data.
 

Excel Facts

What did Pito Salas invent?
Pito Salas, working for Lotus, popularized what would become to be pivot tables. It was released as Lotus Improv in 1989.
On 2002-10-08 20:21, Duncgee wrote:
I have a number of workbooks from which a macro copies data. This data is then pasted into another workbook. How can I have the macro paste the filenames as well as the data.

Hi - welcome to the board!
Care to give a bit more info about where the filenames should go!!

Paddy
 
Upvote 0
What if you got your Macro to place the

=CELL("filename")

formula in a blank cell in the source workbook before copying to the destination, then copy that as a value to the destination workbook. That will give the complete filename, including path and sheet name. If you only want the filename, replace with

=MID(CELL("filename"),FIND("[",A34)+1,(FIND("]",A34)-FIND("[",A34)-1))

HTH

Richard
 
Upvote 0

Forum statistics

Threads
1,219,034
Messages
6,145,893
Members
450,654
Latest member
lorento

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