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
-
2:04:42
TimcastIRL
3 hours agoStock Market BLOODBATH After China Places 34% Tariff On US, Trump HOLDS FIRM | Timcast IRL
141K119 -
LIVE
Alex Zedra
2 hours agoLIVE! Playing Verdansk all night
452 watching -
1:38:36
Glenn Greenwald
5 hours agoProf. John Mearsheimer on Israel's Destruction of Gaza, Trump Admin Attacks on Universities & Speech, Yemen Bombings, Tariffs & Competition with China; Plus: Q&A with Glenn | SYSTEM UPDATE #434
100K51 -
LIVE
SpartakusLIVE
1 day agoThe MACHINE is back after a RESTFUL 4 hours of sleep
319 watching -
LIVE
I_Came_With_Fire_Podcast
10 hours agoTARIFF TAKEOVER | REDCOATS 2.0 | DOGE FINDS SOMETHING HORRIBLE
208 watching -
LIVE
Eternal_Spartan
2 hours agoLive at 9pm Central! Come Hang Out w/ a USMC Vet Playing HALO! Can't Wait to See Everyone!!
103 watching -
LIVE
Welsh Girl
4 hours ago🔴 Minecraft Basics Explained – DAY 1
17 watching -
LIVE
SynthTrax & DJ Cheezus Livestreams
1 day agoFriday Night Synthwave 80s 90s Electronica and more DJ MIX Livestream Trip-Hop SPECIAL EDITION
628 watching -
4:03:27
FusedAegisTV
8 hours agoRumble Smackdown! #001 Street Fighter 6 $500 Online Tournament
38.6K5 -
55:58
BonginoReport
5 hours agoCan Trump Make TikTok Great Again? (Ep. 20) - Nightly Scroll with Hayley Caronia - 04/04/25
118K71