Written by Allen Wyatt (last updated March 29, 2024)
This tip applies to Excel 2007, 2010, 2013, 2016, 2019, and 2021
In other issues of ExcelTips you learn how to create a directory from within a macro. There are times that programmers (even macro programmers) create directories to store temporary files. When they are done, the files are deleted, and the directory is removed. To remove a directory, you use the RmDir command in your macro, as shown here:
RmDir DirName
where DirName is the full pathname of the directory you want to delete. If you do not use a string variable to specify the directory name, then DirName must be enclosed in quotes. If there are any files in the directory or any subdirectories contained in the subdirectory, the command fails with an error. (This means you should delete all the files and subdirectories before trying to remove a directory with RmDir.)
Note:
ExcelTips is your source for cost-effective Microsoft Excel training. This tip (9935) applies to Microsoft Excel 2007, 2010, 2013, 2016, 2019, and 2021. You can find a version of this tip for the older menu interface of Excel here: Removing a Directory.
Professional Development Guidance! Four world-class developers offer start-to-finish guidance for building powerful, robust, and secure applications with Excel. The authors show how to consistently make the right design decisions and make the most of Excel's powerful features. Check out Professional Excel Development today!
When processing information in a macro, you often need to select different cells relative to the currently selected ...
Discover MoreUsing macros to step through each cell in a selection is a common occurrence. What if that selected range is made up of ...
Discover MoreWhen you design your worksheets, you probably want users to interact with those worksheets in specific ways. What ...
Discover MoreFREE SERVICE: Get tips like this every week in ExcelTips, a free productivity newsletter. Enter your address and click "Subscribe."
There are currently no comments for this tip. (Be the first to leave your comment—just use the simple form above!)
Got a version of Excel that uses the ribbon interface (Excel 2007 or later)? This site is for you! If you use an earlier version of Excel, visit our ExcelTips site focusing on the menu interface.
FREE SERVICE: Get tips like this every week in ExcelTips, a free productivity newsletter. Enter your address and click "Subscribe."
Copyright © 2025 Sharon Parq Associates, Inc.
Comments