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

Highlight Duplicates
Home, Conditional Formatting, Highlight Cells, Duplicate records, OK to add pink formatting to any duplicates in selected range.
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,215,583
Messages
6,125,665
Members
449,247
Latest member
wingedshoes

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