Learn Excel - Simplify Life with Excel Concepts

Excel ChDir Function (VBA)

ChDir Function VBA Code

How to use the ChDir Function (VBA)

This Excel tutorial explains how to use the Excel ChDir function with syntax and examples using VBA.


The Excel VBA ChDir function allows you to change the current directory or folder.


To changes the current directory or folder.


The ChDir function does not return any value, but rather changes the current folder or directory on the current drive.


ChDir path


The ChDir function syntax has the following arguments:

  • path: Required. The path argument is a string expression that identifies which directory or folder becomes the new default directory or folder.
    • The path may include the drive.
    • If no drive is specified, ChDir changes the default directory or folder on the current drive.


  • The ChDir statement changes the default directory or folder but does not change the default drive. A different statement, ChDrive, changes the default drive.
    ChDir Function VBA Code

  • On the Power Macintosh, the default drive always changes to the drive specified in path. Full path specifications begin with the volume name, and relative paths begin with a colon (:). ChDir resolves any aliases specified in the path:
    ChDir Function VBA Code

  • If "path" is left blank, then the default directory is changed on the current drive.

Useful Links: Link 1Link 2Link 3Link 4