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

Fastest way to copy a worksheet?
Hold down the Ctrl key while dragging tab for Sheet1 to the right. Excel will make a copy of the worksheet.

PaddyD

MrExcel MVP
Joined
May 1, 2002
Messages
14,234
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
 

RichardS

Well-known Member
Joined
Feb 16, 2002
Messages
761
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
 

Forum statistics

Threads
1,144,329
Messages
5,723,733
Members
422,512
Latest member
MHau5

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
Top