Return to VBA Code Examples

VBA ChDir Statement

ChDir Description

Used to change the current directory or folder.

Simple ChDir Examples

This makes “C:\ProgramData’ the current folder.

The ChDir statement changes the default directory or folder but doesn’t  change the default drive.

So, to change the current folder to the other folder on the other drive, you should use the ChDrive together.

ChDir Syntax

In the VBA Editor, you can type  “ChDir(” to see the syntax for the ChDir Statement:

The ChDir statement contains an argument:

Path: A string expression representing a directory.

Examples of Excel VBA ChDir Function

This changes the current folder to “C:\Program Files (x86)”.

This changes the current folder to “C:\Windows”.

VBA Coding Made Easy

Stop searching for VBA code online. Learn more about AutoMacro - A VBA Code Builder that allows beginners to code procedures from scratch with minimal coding knowledge and with many time-saving features for all users! vba save as

Learn More!