Wednesday, September 14, 2011

Can excel display the file name of the csv file it is connected to in a cell dynamically?

In excel i am connecting to a csv file for data. As i will connect to different files with different data, i want to have a cell that show the file name that it is using at that time. Then when i select a different file for the data i want this to change to the new name of the CSV. Is this possible, and if so how do it do it?Can excel display the file name of the csv file it is connected to in a cell dynamically?You could use %26quot;CELL%26quot; function to display the file name (including full path). For example,



=CELL(%26quot;Filename%26quot;,B2)



where B2=a cell linked to an external source.





shows you the full path.

C:\Users\You\Desktop\[Statement.xlsx]S?br>


If you want to display only the file name, use this formula.



=MID(A1, SEARCH(%26quot;[%26quot;,A1)+1, SEARCH(%26quot;]%26quot;,A1)- SEARCH(%26quot;[%26quot;,A1)-1)



where A1=CELL(%26quot;Filename%26quot;,B2)



Hope this helps.

No comments:

Post a Comment