Written by Allen Wyatt (last updated January 11, 2020)
This tip applies to Excel 2007, 2010, 2013, 2016, 2019, and 2021
Oftentimes it is helpful, in a macro, to specify which drive is considered the default drive. In other words, it may be helpful to indicate the drive on which all file operations should occur when you don't explicitly indicate a drive in a path name. To indicate the default drive to be used in a macro, you use the ChDrive statement, as follows:
ChDrive "E"
This particular statement changes the current drive to E:. You can change to a different drive by simply changing the drive letter enclosed within the quote marks.
Note:
ExcelTips is your source for cost-effective Microsoft Excel training. This tip (9147) 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: Changing the Default Drive.
Comprehensive VBA Guide Visual Basic for Applications (VBA) is the language used for writing macros in all Office programs. This complete guide shows both professionals and novices how to master VBA in order to customize the entire Office suite for their needs. Check out Mastering VBA for Office 2010 today!
When creating macros, you often have to know how to display individual worksheets. VBA provides several ways you can ...
Discover MoreNeed to know the character code used for a particular character? In a macro you can use the Asc function to determine the ...
Discover MoreIf you are getting an error when you try to create an event handler, it could be related to a long-known bug in Excel. ...
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