Skip to content

Instantly share code, notes, and snippets.

@dznz
Created October 29, 2015 22:40
Show Gist options
  • Save dznz/64a34466f44d1a335e75 to your computer and use it in GitHub Desktop.
Save dznz/64a34466f44d1a335e75 to your computer and use it in GitHub Desktop.
Extract the filename from a path in Excel or Google spreadsheet
=TRIM(RIGHT(SUBSTITUTE(A1,"/",REPT(" ",100)),99))
@verkestk
Copy link

riffing on @eiannone's response:

=IFERROR(IF(SEARCH("/",A1,1), TRIM(RIGHT(SUBSTITUTE(A1,"/",REPT(" ",LEN(A1))),LEN(A1)-1))), A1)

Wrapping the TRIM in a conditional that looks for the / character - otherwise the first character gets trimmed improperly.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment