Search code examples
excelexcel-formuladirectory

Get current folder from Excel not working formula


I'm trying to obtain the current forlder from the document with this formula in Excel:

=LEFT(CELL("Book1.xlsx"),SEARCH("\[",CELL("Book1.xlsx")))

But I'm getting an error #VALUE! I'm not sure why, some help with this


Solution

  • To get the full path with filename and sheet name you have to use like this:

    =CELL("filename")
    

    Output: C:\Users\user\Desktop\sample\[example.xls]A Test Sheet

    To get the full path from the current file (previously saved)

    =LEFT(CELL("filename"),FIND("[",CELL("filename"))-1)
    

    Output: C:\Users\user\Desktop\sample\

    Reference