Excel Tip: Automating the Filepath on a Spreadsheet
On the surface it would seem that entering the name of your path and file in the footer (or header) of an Excel worksheet is not an automatic operation. This is such a frequently-requested task, you would think that there would be a quick menu choice to perform this duty. But there is not. In the absence of such a menu selection, here is a quick little macro that you can place in your worksheet that should do the trick.
- Choose Tools, Macro, Macros from the Excel menu.
- Give the macro a name, such as Path or addfilename, then select PERSONAL.XLS as the location for this macro (by placing the macro in the Personal workbook, the macro will be available to all other workbooks).
- Click the Create button to open the visual basic editor where your macro code will be entered. In the Module area on the right side of your screen, between the Sub and the End Sub lines of this macro, enter the following code, all on one line:
- ActiveSheet.PageSetup.RightFooter = ActiveWorkbook.Path & "\" & ActiveWorkbook.Name
- Close the visual basic window by clicking the "x" in the upper right corner. From now on, whenever you wish to place the path and file name in your footer, choose Tools, Macro, Macros, and click on the name of this macro, then click the Run button, and it will appear automatically!
Voice of the Editor
Which isn’t completely true. I mean, occasionally I drop by when I manage to sneak out of the nonstop frat party over at Going Concern, but I’m mostly a wallflower over there. I’m happy to say that I’ve been given express permission (or explicit orders, if you like) to wander over here to AccountingWEB more often.
Why is that, you might ask? My job is to replace the irreplaceable Gail Perry as Editor-in-Chief. What does that mean? I don’t really know! I think it’ll be fun getting a feel for things, throwing in my own thoughts here and there, and listening to the discussions you’re having about the accounting profession.