Written by Allen Wyatt (last updated June 25, 2019)
This tip applies to Excel 97, 2000, 2002, and 2003
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 (2541) applies to Microsoft Excel 97, 2000, 2002, and 2003. You can find a version of this tip for the ribbon interface of Excel (Excel 2007 and later) 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 you need to get rid of characters in the middle of a cell value, the best way to do it is through the use of macros. ...
Discover MoreNeed a quick way to change the default drive and directory in a macro you are writing? Here's the commands to do it and a ...
Discover MoreWhen you delete all the macros in a workbook, Excel may still think you have some there. Here's why that happens and what ...
Discover MoreFREE SERVICE: Get tips like this every week in ExcelTips, a free productivity newsletter. Enter your address and click "Subscribe."
2018-03-02 02:58:10
Dave Alan
Thankyou, this was very helpful, Dave
2018-03-02 02:45:41
Dave Alan
Thankyou, this was very helpful.
Got a version of Excel that uses the menu interface (Excel 97, Excel 2000, Excel 2002, or Excel 2003)? This site is for you! If you use a later version of Excel, visit our ExcelTips site focusing on the ribbon interface.
FREE SERVICE: Get tips like this every week in ExcelTips, a free productivity newsletter. Enter your address and click "Subscribe."
Copyright © 2023 Sharon Parq Associates, Inc.
Comments