Getting cell data from dynamically located and named file

JamesLar

New Member
Joined
Jan 10, 2020
Messages
5
Office Version
  1. 365
Platform
  1. Windows
This may be a little confusing.
I have a sheet that pulls data from another sheet currently using ='O:\inv\2019\[2019 Inventory.xlsm]Dec'!$W$111

Every year I have had to update the links when I save a new annual file from the template.

Is there any way I can have the directory and file referenced using the current file name as a variable. For example for the date I am currently using
Code:
=CONCATENATE(MID(CELL("filename",A1),FIND("]",CELL("filename",A1))+1,255),"-",(RIGHT(LEFT(MID(CELL("filename",A1),FIND("[",CELL("filename",A1))+1,FIND("]",CELL("filename",A1))-FIND("[",CELL("filename",A1))-1),4),2)))
to have the sheet's date show the month and year called from the sheet tabs and the main filename.

I know if I use
Code:
=RIGHT(LEFT(MID(CELL("filename",A1),FIND("[",CELL("filename",A1))+1,FIND("]",CELL("filename",A1))-FIND("[",CELL("filename",A1))-1),4),4)-1
in a file called 2019 Inventory.xlsm it will return a value of 2018. can that code be incorporated into my file reference so as I save the file as a new year it will always call on the previous year's directory and file?

Thanks in advance for any assistance.
 

Excel Facts

Can you sort left to right?
To sort left-to-right, use the Sort dialog box. Click Options. Choose "Sort left to right"
either as a formula or vba would also work if it can do the same idea
 
Upvote 0

Forum statistics

Threads
1,215,527
Messages
6,125,333
Members
449,218
Latest member
Excel Master

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