Text & String Cleaning
Extract Workbook Filename, Folder Path & Sheet Tab Name from File Path (MID + FIND)
Split an Excel CELL("filename") path string like C:\Finance\[FY2026_Budget.xlsx]RevOps_Q4 into its workbook filename, folder directory, and active worksheet tab name.
Why CELL("filename") brackets [Workbook.xlsx] make FIND("[") and FIND("]") the universal path splitter!
When a saved Excel workbook evaluates CELL("filename", A1), it returns a composite path string formatted as FolderPath\[WorkbookName.xlsx]SheetName—for example, C:\Finance\[FY2026_Budget.xlsx]RevOps_Q4! Because the square brackets "[" and "]" cannot appear inside an Excel worksheet tab name, locating open_pos = FIND("[", B2) and close_pos = FIND("]", B2) cleanly isolates all three components without VBA!
Specifically, MID(B2, FIND("[", B2) + 1, FIND("]", B2) - FIND("[", B2) - 1) extracts "FY2026_Budget.xlsx", MID(B2, FIND("]", B2) + 1, 255) extracts the tab name "RevOps_Q4", and LEFT(B2, FIND("[", B2) - 1) extracts the parent directory "C:\Finance\"—while guarding unsaved blank paths with ISERROR(FIND("[", B2))!
| Full CELL("filename") Input B2 | Extracted Workbook Filename | Extracted Sheet Tab | Parent Folder Path |
|---|---|---|---|
| C:\Finance\[FY2026_Budget.xlsx]RevOps_Q4 | FY2026_Budget.xlsx | RevOps_Q4 | C:\Finance\ |
| /Cloud/FP&A/[Q3_Forecast.xlsx]Cash_Flow | Q3_Forecast.xlsx | Cash_Flow | /Cloud/FP&A/ |
| "" (Unsaved Workbook — Blank String) | "Unsaved Workbook" | "Unsaved Workbook" | "Unsaved Workbook" |
Extract Workbook Filename Only Between "[" and "]"
Extracts the exact workbook filename (including extension) between square brackets, returning "Unsaved Workbook" when no bracketed path exists.
=IF(OR(ISERROR(FIND("[", B2)), ISERROR(FIND("]", B2))), "Unsaved Workbook", MID(B2, FIND("[", B2) + 1, FIND("]", B2) - FIND("[", B2) - 1))Extract Worksheet Tab Name After "]" & Parent Folder Path Before "["
Extracts up to 255 characters after "]" for the worksheet tab name (Excel limits tab names to 31 characters), or LEFT(B2, FIND("[", B2) - 1) for the folder path.
=IF(ISERROR(FIND("]", B2)), "Unsaved Workbook", MID(B2, FIND("]", B2) + 1, 255))Try the example
Use the original values or change them to test your understanding.