Premium Only Content

Excel VBA: Check If File or Folder Exists (DIR) - Open File or Create Folder
November 22, 2018 Excel VBA & Macros Tutorials
Use the DIR function in Excel VBA to check if a file or a folder exist. You can then decide what to do if they exist. For example you can open the Workbook to copy values from and then close the workbook.
I will also show you how you can handle cases where the file does not exist or the file name is not typed correctly. In that case VBA generates an error but you can easily avoid with the IF statement.
[5:10] I also show you how you can check with VBA if a folder exists. and if it doesn't exist, how you can create the folder. We use the message box function to ask the user for permission if we should create the folder or not.
🡻 Download the workbook here: https://www.xelplus.com/excel-vba-check-if-file-folder-exists-dir/
★ Links to related videos: ★
Learn about declaring variables in VBA: https://youtu.be/zfc9TYH3UvY
Complete Excel VBA free course (playlist): https://www.youtube.com/playlist?list=PLmHVyfmcRKyzmbDy6QoBuUDrU5D-jD-Se
★★ My Online Excel Courses ★★
Courses ► https://courses.xelplus.com/
✉ Subscribe & get my TOP 10 Excel formulas e-book for free
https://www.xelplus.com/free-ebook/
★ Excel Resources I Recommend
https://www.xelplus.com/resources/
Get Office 365: https://microsoft.msafflnk.net/15OEg
Microsoft Surface: https://microsoft.msafflnk.net/c/1327040/451518/7593
GEAR
Camera: https://amzn.to/2FLiFho
Screen recorder: http://techsmith.pxf.io/c/1252781/347799/5161
Microphone: https://amzn.to/2DVKstA
Lights: http://amzn.to/2eJKg1U
Note: This description contains affiliate links, which means at no additional cost to you, we will receive a small commission if you make a purchase using the links. This helps support the channel and allows us to continue to make videos like this. Thank you for your support!
#ExcelVBA
-
LIVE
Game On!
15 hours agoJalen Hurts DODGES Trump! Skips Team White House Visit!
11,125 watching -
LIVE
BEK TV
22 hours agoTrent Loos in the Morning 4/29/2025
7,474 watching -
5:52
MichaelMotamedi
11 hours ago $2.48 earnedEating The Most Elusive Lobster In The World
14K17 -
11:03
Melonie Mac
13 hours agoClair Obscure Expedition 33 Has Saved Gaming
24.2K28 -
7:39
The Shannon Joy Show
15 hours ago🇺🇸 America's Breaking Point: Are We Ready to Toss the Board? 🎯
18.9K16 -
10:00
Adam Does Movies
19 hours ago $2.86 earnedCEO Claims Netflix Saved Hollywood. Um, WHAT?!?! - Rant
31.5K8 -
1:00:43
Trumpet Daily
20 hours ago $5.25 earnedThat Big, Beautiful Wall Around the Vatican - Trumpet Daily | Apr. 28, 2025
17.1K16 -
12:40
Degenerate Jay
12 hours ago $0.62 earnedThe Perfect RoboCop Versus Terminator Game Needs To Be Made!
20.1K5 -
8:17
VSOGunChannel
16 hours ago $0.83 earnedYou Were Put on a Government Watch List || DECLASSIFIED
20.4K7 -
35:14
Steph & Kayls
18 hours ago $0.97 earnedSpicing Things Up: How To Navigate Adding A Third To The Bedroom | Ep. 4
24.3K11