CSV File name to show in A2

bobaol

Board Regular
Joined
Jun 3, 2002
Messages
225
Office Version
  1. 365
  2. 2003 or older
Platform
  1. Windows
Hello, how do I get a .csv file to show ONLY the file name in A2? and if possible, to show the sheet name in A3? I currently use =CELL("filename") in A1, but that comes up with C:\temp2\6489\TankMan.csv However, I do not want the full path, I only want the file name. Any help is appreciated. Thanks in advance.
 

Excel Facts

When did Power Query debut in Excel?
Although it was an add-in in Excel 2010 & Excel 2013, Power Query became a part of Excel in 2016, in Data, Get & Transform Data.
Excel Formula:
=TEXTAFTER(A2,"\",-1)
Excel Formula:
=TEXTAFTER(CELL("filename"),"]",-1)
 
Upvote 0
I suggest that you update your Account details (or click your user name at the top right of the forum) so helpers always know what Excel version(s) & platform(s) you are using as the best solution often varies by version. (Don’t forget to scroll down & ‘Save’)
 
Upvote 1
Which Excel version are you using? Should update that in your Account Details.
Edit: @Joe4 beats me to it :)
 
Upvote 1
worked perfectly. for non-Excel files =TEXTAFTER(CELL("filename"),"\",-1) for Excel file =TEXTAFTER(CELL("filename"),"]",-1) Thank you everyone. I love MrExcel and all y'all. U D best!
 
Upvote 0
Hi, just wanted to share this issue. Earlier, life was perfect with the Textafter function. However, 8 hours later, the Textafter function no longer appears on my version Excel. Weird. i restarted my machine. Redirecting
Anyone with any ideas on why a function simply disappears? Is it this MS Enterprise License issue, where a person would have to pay to get certain functions to work in one version, but if not paid, then the other versions will not support the function? any help is appreciated. thanks in advance.
 
Upvote 0
That's strange. However with Excel, there is always more than one way to do something.

tmp1.xlsm.xlsx
AB
1C:\temp2\6489\TankMan.csvTankMan.csv
2Sheet1
Sheet1
Cell Formulas
RangeFormula
B1B1=TRIM(RIGHT(SUBSTITUTE(A1,"\",REPT(" ",100)),50))
B2B2=TRIM(RIGHT(SUBSTITUTE(CELL("filename"),"]",REPT(" ",100)),50))
 
Upvote 0
Solution
Works. learning new stuff all the time. really appreciate it. Thank you!
 
Upvote 0

Forum statistics

Threads
1,223,903
Messages
6,175,284
Members
452,630
Latest member
OdubiYouth

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