Display workbook file path

To display the current/active workbook file path in a cell we can use an Excel or a VBA method

Example: Display workbook file path

Display workbook file path

METHOD 1. Display workbook file path

EXCEL

=LEFT(CELL("filename",A1),FIND("[",CELL("filename",A1))-1)
This formula returns the file path of the workbook in which the formula is written in.

METHOD 1. Display workbook file path using VBA

VBA

Sub Display_workbook_file_path()
'display the workbook's file path
ActiveSheet.Range("B5") = Application.ActiveWorkbook.Path

End Sub

ADJUSTABLE PARAMETERS
Output Range: Select the output range by changing the cell reference ("B5") in the VBA code to any cell in the worksheet, that doesn't conflict with the formula.

ADDITIONAL NOTES
Result: This VBA code will display the workbook file path without the "\" at the end of the file path. To insert "\" at the end of the file path replace the VBA code with ActiveSheet.Range("B5") = Application.ActiveWorkbook.Path & "\ ".

Explanation about the formula used to display workbook file path

EXPLANATION

EXPLANATION
To display the current/active workbook file path in a cell we can use an Excel or a VBA method.
FORMULAS
=LEFT(CELL("filename",A1),FIND("[",CELL("filename",A1))-1)

ARGUMENTS
A1: A1 is the cell reference, to cell (A1), of the the sheet where the formula is written.